前提・実現したいこと
あるちょっとしたゲームを制作しているのですが、
UI内に入っている変数の値または、bool値が更新されても取得できません。
最初設定してあるbool値falseは取得ができるのですが
そこから、その値がtrueになった更新後の値がなぜか取得ができず
取得している値はずっとfalseのままです。
どうしたら良いのでしょうか?
発生している問題・エラーメッセージ
エラーメッセージは全く出ていません。
該当のソースコード
UI内にあるスクリプト
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using UnityEngine.UI; 5 6public class ShopBSScp : MonoBehaviour 7{ 8 public Text MoneyText; 9 public Text DescriText; 10 public int Money = 0; 11 public int BUYConFirint = 0; 12 public bool BUYFlg = false; ←このbool値を取得したい 13 public bool Flg = false; 14 15 // Start is called before the first frame update 16 void Start() 17 { 18 19 } 20 21 // Update is called once per frame 22 void Update() 23 { 24 if(左クリックされたら) 25 { 26 BUYFlg = true; 27 } 28 } 29 30}
別オブジェクトにあるスクリプト
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using UnityEngine.UI; 5 6public class HitoStatusScp : MonoBehaviour 7{ 8 public ShopBSScp ShopBSscp; ←ここでスクリプトを指定 9 public int SwordStatus = 0; 10 public int ShieldStatus = 0; 11 public int ItemStatus = 0; 12 13 public bool TPStatus = true; 14 15 16 // Start is called before the first frame update 17 void Start() 18 { 19 20 } 21 22 // Update is called once per frame 23 void Update() 24 { 25 if(ShopBSscp.BUYFlg == true) ←ここでbool値を取得 26 { 27 ShopBSscp.BUYFlg = false; 28 BUYSpriteChange(); 29 } 30 }
publicを使い該当のスクリプトを指定し、
public化されている変数を取得しようとしています。
ちなみにUI内にあるスクリプトは
外部から見たら、しっかりとBUYFlgがtrueになっているんですが、
別オブジェクトからのdebugはずっとfalseのままでした。
補足情報(FW/ツールのバージョンなど)
2019.1.0f2
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/07/29 02:23
2019/07/29 02:49 編集