1.查找子级组件
public GameObject enemyGos;
enemyGos.GetComponentInChildren<BoxCollider>();
enemyGos.GetComponentsInChildren<BoxCollider>();
2.查找父级组件
enemyGos.GetComponentInParent<BoxCollider>();
enemyGos.GetComponentsInParent<BoxCollider>();
1.查找子级组件
public GameObject enemyGos;
enemyGos.GetComponentInChildren<BoxCollider>();
enemyGos.GetComponentsInChildren<BoxCollider>();
2.查找父级组件
enemyGos.GetComponentInParent<BoxCollider>();
enemyGos.GetComponentsInParent<BoxCollider>();
1.No5_Component no5_Component=gameObject.GetComponent<No5_Component>();
1.Destroy(),静态方法,销毁游戏物体
2.FindObjectOfType(),静态方法
3.Instantiate()
4.
MonoBehaviour
1. enabled:成员变量,组件激活状态
2.name:成员变量,组件挂载的对象名称
3.tag:成员变量,组件挂载的标签名称
4.isActiveAndEnabled:成员变量,组件是否已激活并启用Behaviour
1.GameObject[] enemyGos=GameObject.FindGameObjectsWithTag(“ Enemy”);
2.BoxCollider[] colliders=GameObject.、findObjectOfType<BoxCollider>();
1.通过标签查找
GameObject.FindGameObject WithTag(“MainCamera”);
2.通过类型查找
No2_EventFunction no2_EventFunction= GameObject.FindObjectOfType<No2_EventFunction>();
1.activeInHierarchy:成员变量,游戏物体的激活或失活状态
2.activeSelf:成员变量,游戏物体的激活或失活状态
3.通过名称查找
GameObject mainCameraGo = GameObject.Find(“Main Camera”);
1.Instantiate:静态方法,实例化克隆
2. CreatePrimitive:静态方法,创建原始几何体
3.SetActive:成员方法,激活或失活游戏物体
4.tag:成员变量,标签
5.layer:成员变量,层级
创建游戏物体方式
1.使用构造函数
GameObject myGo = new GameObject("MyGameObject");
2.根据现有的预制体(游戏物体)资源或者游戏场景已有的游戏物体来实例化。
GameObject.Instantiate(grisGo);
3.使用特别的API创建
OnApplicatoinquit()
LateUpdate()
Start()
OnEnable()
1.
Awake()
Mute 静音
yancdiaoyogn
按下左键是0
右键是1
中键是2
awake只有首次激活调用,
onenable激活一次调用一次
int a =0;