繁体   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