こんにちは。
ボタンが押されたときに壁を非表示にするシステムを作りたいです。
publicを使って別のテキストでも変数が通用するようにしたのですが、壁のほうのテキストのif文に変数の変換をつけたいのです。
参考書や検索を何度も試しましたが、どうしてもわかりません。
外部からの変数の変換に対応させるためにはどうすればいいかわかるサイトか何かありませんか?
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class ButtonScript : MonoBehaviour 6{ 7 8 //宣言 9 public int botton = 0; 10 11 // Start is called before the first frame update 12 void Start() 13 { 14 15 } 16 17// ボタンが押されたときbottonの数値を1にすることで1にした場合のイベントを起こす疑似スイッチ 18 public void OnClick () 19 { 20 int botton; 21 botton=1; 22 Debug.Log(botton); 23 } 24 // Update is called once per frame 25 void Update() 26 { 27 28 } 29} 30
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class 壁変更 : MonoBehaviour 6{ 7 // Start is called before the first frame update 8 void Start() 9 { 10 11 } 12 13 // Update is called once per frame 14 void Update() 15 { 16 int botton = 0; 17 if(botton == 1) 18 { 19 gameObject.SetActive(false); 20 } 21 } 22} 23
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/01/30 07:15