成就系统 巨大修改 新的ui 黑白效果 等一堆
This commit is contained in:
@@ -1,30 +1,37 @@
|
||||
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class runningTime : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
|
||||
public TextMeshProUGUI allRunningTime;
|
||||
public AudioSource bgMusicAudioSource;
|
||||
public AudioSource bgMusicAudioSource; // optional: can be assigned in inspector
|
||||
|
||||
private bool isPlayingSong = false;
|
||||
private GameManager gm;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// allRunningTime.text = "0.00";
|
||||
gm = FindObjectOfType<GameManager>();
|
||||
if (bgMusicAudioSource == null && gm != null)
|
||||
{
|
||||
bgMusicAudioSource = gm.musicSource;
|
||||
}
|
||||
|
||||
// ensure UI shows zero initially
|
||||
if (allRunningTime != null)
|
||||
allRunningTime.text = "0.00";
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
allRunningTime.text = Time.time.ToString("F2");
|
||||
if (Time.time > 0 && isPlayingSong == false)
|
||||
// Only display playback time after the game manager indicates playback actually started
|
||||
if (gm != null && gm.PlaybackStarted && bgMusicAudioSource != null && bgMusicAudioSource.isPlaying)
|
||||
{
|
||||
bgMusicAudioSource.Play(4);
|
||||
isPlayingSong = true;
|
||||
return;
|
||||
allRunningTime.text = bgMusicAudioSource.time.ToString("F2");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (allRunningTime != null)
|
||||
allRunningTime.text = "0.00";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user