前提・実現したいこと
オブジェクトRight
をクリックしたときにTextのScore
に100点ずつ加算していく。
発生している問題・エラーメッセージ
クリックするたびにdebugの処理は実行されるものの加算処理が1回しか実行されない。
該当のソースコード
C#
1using UnityEngine; 2using UnityEngine.EventSystems; 3using UnityEngine.UI; 4 5public class Right : MonoBehaviour, IPointerClickHandler 6{ 7 int Point = 0; 8 GameObject Score; 9 void Start() 10 { 11 this.Score = GameObject.Find("Score"); 12 } 13 14 public void OnPointerClick(PointerEventData eventData) 15 { 16 if (true) 17 { 18 Point += 100; 19 Debug.Log("CHECK NOW"); 20 } 21 this.Score.GetComponent<Text>().text = this.Point.ToString("F0"); 22 Destroy(gameObject); 23 } 24}
試したこと
if文のまえにwhile文を入れたがunityが処理落ちしてしまった。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/25 02:20 編集
2019/03/25 02:37
2019/03/25 07:12