您好,登錄后才能下訂單哦!
效果圖
實現(xiàn)步驟要點:
1、添加Cube游戲
2、創(chuàng)建預(yù)設(shè)對象
3、創(chuàng)建空游戲?qū)ο?,用于綁定?zhí)行預(yù)設(shè)代碼
4、選中g(shù)ameObject在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; } }
方法一:通過檢查器直接獲取預(yù)設(shè)對象
方法二:代碼獲取,把代碼修改
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; } }
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。