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