前提・実現したいこと
「unityで作るリズムゲーム」という本を参考にして、音ゲーを作っています。
ゲーム中に判定を表示するスプリクトを書いているのですが、文字が表示されません。
判定はJudgementTypeという名前の列挙型にまとめられており、別のスプリクトで定義されています。
UnityやC#を始めてからそこまで長くないので、知識が足りないかもしれません、よろしくお願いします。
発生している問題・エラーメッセージ
判定が表示できない
該当のソースコード
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using UnityEngine.UI; 5 6public class Judgetiming : MonoBehaviour{ 7public GameObject score_object = null; 8 9 void OnKeyDown(JudgementType judgementType) 10 { 11 Text score_text = score_object.GetComponent<Text> (); 12 switch(judgementType){ 13 case JudgementType.Miss: 14 score_text.text = "Miss"; 15 score_text.color = new Color(0.2f, 0.2f, 0.5f, 1.0f); 16 score_object.gameObject.SetActive(true); 17 break; 18 19 case JudgementType.Bad: 20 score_text.text = "Bad"; 21 score_text.color = new Color(0.0f, 0.0f, 0.5f, 1.0f); 22 score_object.gameObject.SetActive(true); 23 break; 24 25 case JudgementType.Good: 26 score_text.text = "Good"; 27 score_text.color = new Color(1.0f, 0.92f, 0.015f, 1.0f); 28 score_object.gameObject.SetActive(true); 29 break; 30 31 case JudgementType.Perfect: 32 score_text.text = "Perfect"; 33 score_text.color = new Color(1.0f, 0.0f, 1.0f, 1.0f); 34 score_object.gameObject.SetActive(true); 35 break; 36 } 37} 38}
試したこと
・ノーツの設定をするスプリクトに書く
・Text形式ではなくて画像読み込みにする
・if文を使う
・string.Formatメゾットを使う
補足情報(FW/ツールのバージョンなど)
Unity 2019.2.19f1
参考:unityで作るリズムゲーム
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。