オブジェクトに("Cube")のタグを付けGetKeyを使って表示非表示にしたいと思ってます。
しかし、非表示にした後は表示ができません。
タグをつけたのは、instantiateで元のオブジェクトとプレハブ化したオブジェクトを表示非表示したい為です。
いろいろ調べましたが、解決法がわからずでした。
よろしお願いします。
c#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class NewBehaviourScript : 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 if (Input.GetKey(KeyCode.Space)) 17 { 18 GameObject[] b = GameObject.FindGameObjectsWithTag("Cube"); 19 foreach (GameObject a in b) 20 { 21 a.SetActive(true); 22 } 23 24 } 25 if (Input.GetKey(KeyCode.LeftShift)) 26 { 27 GameObject[] b = GameObject.FindGameObjectsWithTag("Cube"); 28 foreach (GameObject a in b) 29 { 30 a.SetActive(false); 31 } 32 33 } 34 } 35} 36
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/09 13:08 編集