其他分享
首页 > 其他分享> > UNITY实例化预制体

UNITY实例化预制体

作者:互联网

using UnityEngine;

public class TestPrefabs : MonoBehaviour
{
    public GameObject cubeObject;

    //void Start()
    //{
    //    Instantiate(cubeObject, transform.position, transform.rotation);
    //}

    void Update()
    {
        Instantiate(cubeObject, transform.position, transform.rotation);
    }
}

  然后将改脚本挂在到Cube上,成为其组件的一部分,然后将预制体中的Cube填充GameObject cubeObject(将其拖动到public组件框中)

标签:Cube,void,Instantiate,transform,UNITY,实例,cubeObject,预制,public
来源: https://www.cnblogs.com/guangzhiruijie/p/15825010.html