簡體   English   中英

(C# Unity) 停止計時器並在另一個場景中顯示停止時間

[英](C# Unity) Stoping timer and showing the stopped time in another scene

這是我的計時器腳本,我想停止播放並在另一個場景中顯示時間。 我需要做什么才能做到這一點?

'使用 UnityEngine;'

'使用 UnityEngine.UI;'

'公共類 UITimer : MonoBehaviour'

'{

 'public Text TimerText;'

 'public bool playing;'

 'private float Timer;'

'無效更新(){'

      'if(playing == true){'

      'Timer += Time.deltaTime;'

      'int minutes = Mathf.FloorToInt(Timer / 60f);'

      'int seconds = Mathf.FloorToInt(Timer % 60f);'

       'int milliseconds = Mathf.FloorToInt((Timer * 100f) % 100f);'

      'TimerText.text = minutes.ToString ("00") + ":" + seconds.ToString ("00") + ":" +'

      'milliseconds.ToString("00");'
'}'

'}'

'}'

在 StackOverflow 上搜索后,我找到了這個響應,它為您提供了幾個選項: https : //stackoverflow.com/a/44542726/17331768

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM