前提・実現したいこと
今Unityを使って3Dゲームを作成しているのですが、C#のスクリプトを改造してUnity内でPlayをする時にクラッシュが発生して「we will now try to find a fix for the crash 」の文が出てきます。対処法や発生原因がわかる方がいらっしゃれば教えて頂きたいです。初質問なので所々不手際があるかもしれませんがお許しを……
発生している問題・エラーメッセージ
we will now try to find a fix for the crash
該当のソースコード
C#
1 2using System.Collections; 3using System.Collections.Generic; 4using UnityEngine; 5using UnityEngine.UI; 6using UnityEngine.SceneManagement; 7 8public class Timecount : MonoBehaviour { 9 10 private int minute; 11 private float seconds; 12 //前のUpdate時の秒数 13 private float oldSeconds; 14 //タイマー表示テキスト 15 private Text timerText; 16 17 // Use this for initialization 18 void Start () { 19 minute = 1; 20 seconds = 0; 21 oldSeconds = 0; 22 timerText = this.GetComponent<Text>();//Textコンポーネントを取得 23 24} 25 26// Update is called once per frame 27void Update () { 28 seconds -= Time.deltaTime; 29 if (seconds <= 0f) 30 { 31 minute--; 32 seconds = seconds +60; 33 } 34 35 //値が変わった時のみテキストUIを更新 36 if ((int)seconds != (int)oldSeconds) 37 { 38 timerText.text=minute.ToString("00")+":"+((int)seconds).ToString("00"); 39 } 40 oldSeconds = seconds; 41 if (minute == 0 && seconds >= 0) 42 { 43 SceneManager.LoadScene("Result"); 44 } 45 46} 47 48} 49
試したこと
Unityの再起動
PC本体の再起動
補足情報(FW/ツールのバージョンなど)
Play以外は全て問題なく動きます。
メモリ、CPUも35%程なので問題無しと思われます。
Unityはversion.2018.2.10です。
これだけの情報で原因を探るのは無理です。
以下の内容も記載してください。
- 「C#のスクリプトを改造して」とあるが、具体的に何をどう改造したのか
- Consoleウィンドウにエラーが出ている場合、その内容
質問する際は以下の内容も確認するとよろしいと思います。
https://teratail.com/help/question-tips
すいません。返信が遅くなってしまいました。
具体的にはUnity内で時間をカウントするスクリプトを作っていて、最初はカウントが1つずつ上がるように作っていたのですが、途中でマイナスカウントするように作り替えることになったので改造をしていた所クラッシュするようになりました。
ソースコードの方にスクリプトを貼らせていただきました。

回答1件
あなたの回答
tips
プレビュー