6970人加入学习
(26人评价)
Unity常用API方法与类详细讲解 - 知识理论篇

制作完成于2022年3月8日,基于Unity2020.3

价格 免费

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创建

[展开全文]

按下左键是0

右键是1

中键是2

[展开全文]

awake只有首次激活调用,

onenable激活一次调用一次

[展开全文]

授课教师

SiKi学院老师

课程特色

视频(110)
图文(2)
下载资料(2)