using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class GameCanvas : MonoBehaviour { public Text timeText; public static GameCanvas ins; void Start() { ins = this; } void Update() { RefreshRender(); } void RefreshRender() { RenderTime(GameController.ins.time); RenderScore(0, GameController.ins.scores[0]); RenderScore(1, GameController.ins.scores[1]); } void RenderTime(float time) { timeText.text = GetTimeStr(time); } void RenderScore(int playerIndex, float score) { transform.Find("ScoreBG" + (playerIndex + 1)).GetComponentInChildren().text = "玩家得分" + (float)System.Math.Round(score, CommonConfig.ringsPrecision); } string GetTimeStr(float time) { int seconds = (int)Mathf.Ceil(time); string str = ""; int m = seconds / 60; if (m < 10) { str += 0; } str += m; str += " : "; int s = seconds % 60; if (s < 10) { str += 0; } str += s; return str; } }