前提・実現したいこと
スクリプトInstant
からPrefabのRight1
とFlash
のオブジェクトを生成したい。
発生している問題・エラーメッセージ
Assets\Stage2\Script\Instantiate2n1.cs(9,16): warning CS0649: Field 'Instantiate2n1.Right1' is never assigned to, and will always have its default value null
該当のソースコード
C#
1using UnityEngine; 2 3public class Instant : MonoBehaviour 4{ 5 bool a; bool b; 6 GameObject Right1; 7 GameObject Flash; 8 void Start() 9 { 10 a = true; b = true; 11 GameObject Right1 = (GameObject)Resources.Load("Right1"); 12 GameObject Flash = (GameObject)Resources.Load("Flash"); 13 } 14 void Update() 15 { 16 if (a == true) 17 { 18 Instantiate(original: Flash, position: new Vector3(0.0f, 0.0f, 0.0f), rotation: Quaternion.identity); 19 a = false; 20 } 21 22 if (b == true) 23 { 24 Instantiate(original: Right1, position: new Vector3(0.0f, 0.0f, 0.0f), rotation: Quaternion.identity); 25 b = false; 26 } 27 } 28}
試したこと
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/04 09:43