Unityで1秒毎にPrefabを生成して下に落ちて消えるようにしたいのですが
Hierarchy上では生成されているのですが画面上にはなぜか1つも表示されません。
どこがおかしいのでしょうか?
環境)
PC: mac
Unity2018.2
言語:C#
DownScript.cs(下に落ちすスクリプト:オブジェクトにアタッチしてprefab化しました)
using System.Collections; using System.Collections.Generic; using UnityEngine; public class DownScript : MonoBehaviour { // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { transform.Translate(0,-0.1f,0); if(transform.position.y < -5.0f){ Destroy(gameObject); } } }
SlotScript.cs(prefabを1秒毎に生成するスクリプト:空のGameObjectを作成してアタッチしました)
using System.Collections; using System.Collections.Generic; using UnityEngine; public class SlotScript : MonoBehaviour { public GameObject slotLPrefab; float span = 1.0f; float delta = 0; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { delta += Time.deltaTime; if(delta > span){ delta = 0; GameObject instanseL = Instantiate(slotLPrefab) as GameObject; instanseL.transform.position = new Vector3(0, 7, 0); } } }
Hierarchyではクローンはできていますが画面上には何も表示されません。
prefabの設定はこんな感じです。
canvasのインスペクター
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。