前提・実現したいこと
時間制限のゲームを作っています。ゲームオーバーしてリロードしたとき制限時間をリセットしたいです。
発生している問題・エラーメッセージ
リロードしたとき、他のオブジェクトは初期状態に戻るが、制限時間のみもとに戻らない(0のまま)
該当のソースコード
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using UnityEngine.UI; 5 6public class timer : MonoBehaviour 7{ 8 public Text TimerText; 9 public static float total = 60; 10 int time; 11 12 // Start is called before the first frame update 13 void Start() 14 { 15 16 } 17 18 // Update is called once per frame 19 void Update() 20 { 21 total -= Time.deltaTime ; 22 time = (int)total; 23 TimerText.text = time.ToString(); 24 if(total < 0){ 25 total = 0; 26 } 27 } 28}
補足情報
リロードはSceneManager.LoadScene("今のScene");で現在のシーンを呼び出しています
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/23 06:45