《Unity API常用方法和类详细讲解—Siki学院》课程学习笔记02
《Unity API常用方法和類詳細(xì)講解—Siki學(xué)院》課程學(xué)習(xí)筆記02
課時(shí)10 GameObject、Component和Object的千絲萬縷的關(guān)系
一個(gè)游戲由多個(gè)場(chǎng)景組成,一個(gè)場(chǎng)景由多個(gè)游戲物體(GameObject)組成,一個(gè)游戲物體由多個(gè)組件組成(Component);
組件:Transform, Rigidboy, MeshRender, MeshFilter, Collider, NavmeshAgent, Animation, Animator,自定義腳本(Script)
課時(shí)11-12 UnityEngine下Object的靜態(tài)方法以及GameObject獨(dú)有的靜態(tài)方法
Destroy():可以銷毀游戲物體和組件;
DontDestroyOnLoad(gameobject):設(shè)置共享的游戲物體,重新調(diào)整場(chǎng)景時(shí)不會(huì)銷毀;
FindObjectOfType()根據(jù)類型獲取組件;
FindObjectsOfType()根據(jù)類型返回組件數(shù)組;
GameObject.Find(“Main Camera”);根據(jù)名稱獲得主相機(jī);
GameObject.FindGameObjectsWithTag(“Main Camera”);根據(jù)標(biāo)簽獲得主相機(jī);
課時(shí)13 游戲物體間消息的發(fā)送和接收
(1)GameObject.BroadcastMessage(string methodName, object parameter = null, SendMessageOptions options = SendMessageOptions.RequireReceiver); //發(fā)送該節(jié)點(diǎn)的所有子節(jié)點(diǎn)
(2)GameObject.SendMessage(string methodName, object value = null, SendMessageOptions options = SendMessageOptions.RequireReceiver); //發(fā)送給物體本身
(3)GameObject.SendMessageUpwards(string methodName, object value = null, SendMessageOptions options = SendMessageOptions.RequireReceiver); //發(fā)送給其所有父節(jié)點(diǎn)
課時(shí)14得到組件各種方法函數(shù):
GetComponent<組件類型>();
GetCompoents<組件類型>();
GetCompoentsInChilren<組件類型>();
GetComponentsInChildren<組件類型>();
GetComponentInParent<組件類型>();
GetCompoentsInParent<組件類型>();
課時(shí)15-17MonoBehavior部分總結(jié)
(1)得到組件的各種方法函數(shù)
GetComponent;只會(huì)得到在游戲物體身上的第一個(gè)檢測(cè)到的組件
GetComponent;會(huì)得到物體上所有的組件
GetComponentInChildren;會(huì)得到其自身及其子物體身上第一個(gè)檢測(cè)到的相應(yīng)的組件
GetComponentInParent;會(huì)得到其自身及其父物體身上第一個(gè)檢測(cè)到的相應(yīng)的組件
GetComponentsInChildren;會(huì)得到其自身及其子物體身上所有檢測(cè)到的相應(yīng)的組件
GetComponentsInParent;會(huì)得到其自身及其父物體身上所有檢測(cè)到的相應(yīng)的組件
(2)公共函數(shù)
Public void Invoke(string methodName,float time );延時(shí)調(diào)用函數(shù)
CancelInvoke;取消所有調(diào)用的函數(shù)(僅適用于當(dāng)前腳本)
InvokeRepeating;重復(fù)調(diào)用函數(shù)
(3)Invoke的使用詳解
總結(jié)
以上是生活随笔為你收集整理的《Unity API常用方法和类详细讲解—Siki学院》课程学习笔记02的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql查询数据库ppt_数据库与数据
- 下一篇: c++简易倒计时