游戏对象的操作

1. 创建游戏对象

GameObject gObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
public enum PrimitiveType
    {
        Sphere,    
        Capsule,
        Cylinder,
        Cube,
        Plane,
        Quad
    }

2. 查找游戏对象

a.  通过对象名称获取游戏对象

       GameObejct objcet = GameObject.Find(path); 对象在Hierarchy中的完整路径

   b. 通过标签获取单个游戏对象

       GameObject obejct = GameObject.FindWithTag(name)

   c .通过标签获取多个游戏对象

      GameObject[] objects = GameObject.FindGameObjectsWithTag ("cube1");

3. 删除游戏对象

     Destroy (objects[0]);

4. 添加游戏组件:

   object.addComponent(Rigidbody);

原文地址:https://www.cnblogs.com/zhangweia/p/3645448.html