Unity脚本实现添加子物体

2020-12-02 09:47

阅读:525

标签:部分   anti   name   实现   art   load   one   使用   void   

主要部分:

public GameObject prefab; //使用预制添加子物体

void Start () {

//f 为需要添加自物体的对象

GameObject fg = GameObject.Find("f");

//第一种 clone

//GameObject _Instance = Instantiate(prefab);

//_Instance.transform.parent =fg.transform;

//第二种 从Resources里进行加载

GameObject pfb = Resources.Load("name") as GameObject;

GameObject _Instance = Instantiate(pfb);

_Instance.transform.parent = f.transform;

}

 

Unity脚本实现添加子物体

标签:部分   anti   name   实现   art   load   one   使用   void   

原文地址:https://www.cnblogs.com/allyh/p/10987115.html


评论


亲,登录后才可以留言!