1、GameObject中的成员变量
// 名字 this.gameObject.name // 是否激活 this.gameObject.activeSelf // 是否为静态 this.gameObject.isStatic // 层级 this.gameObject.layer(返回int类型,层级前面的标号) // 标签 this.gameObject.tag(返回string类型) // transform this.transform,通过Mono去得到的依附对象的GameObject的位置信息 与this.gameObject.transform得到的相同
2、GameObject中的静态方法
// 创建自带几何体,参数为几何体类型(PrimitiveType枚举),返回一个GameObject对象,只要得到一个GameObject对象,就可以得到它身上挂载的任何脚本信息,通过obj.GetComponent方法得到
GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Cube) obj.name = "****"; obj.transform.position = new Vector3(*,*,*);
// 查找对象相关的知识
// PS:只能找到被激活的对象
(1)查找单个对象
// 如果场景中存在多个满足条件的对象,无法确定找到的是谁
// 通过对象名查找,若没有找到返回null
// 效率低下,因为会在场景中的所