日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

《Unity API常用方法和类详细讲解—Siki学院》课程学习笔记02

發布時間:2024/3/24 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 《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的使用詳解

using System.Collections; using System.Collections.Generic; using UnityEngine; public class API07Invock : MonoBehaviour {// Start is called before the first frame updatevoid Start(){// Invoke("Attack",3);InvokeRepeating("Attack",3,5);CancelInvoke();}// Update is called once per framevoid Update(){bool res=IsInvoking("Attack");print(res);}void Attack() {print("開始攻擊");} }

總結

以上是生活随笔為你收集整理的《Unity API常用方法和类详细讲解—Siki学院》课程学习笔记02的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。