您好,登錄后才能下訂單哦!
效果圖
實現步驟要點:
1、添加Cube游戲
2、創建預設對象
3、創建空游戲對象,用于綁定執行預設代碼
4、選中gameObject在Inspector檢查器中添加和綁定以下代碼
using UnityEngine; using System.Collections; public class prefab : MonoBehaviour { public GameObject ViewCenter; private float i=-10.0f; // Use this for initialization void Start () { } // Update is called once per frame(Pre, transform.position, transform.rotation); void Update () { if (i < 1f) { i++; } GameObject instance=Instantiate(ViewCenter,transform.position*i,transform.rotation) as GameObject; } }
方法一:通過檢查器直接獲取預設對象
方法二:代碼獲取,把代碼修改
using UnityEngine; using System.Collections; public class prefab : MonoBehaviour { public GameObject ViewCenter; private float i = -10.0f; // Use this for initialization void Start () { ViewCenter = GameObject.Find ("gameObject"); } // Update is called once per frame(Pre, transform.position, transform.rotation); void Update () { if (i < 1f) { i++; } GameObject instance = Instantiate (ViewCenter, transform.position * i, transform.rotation) as GameObject; } }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。