一、Object and Component
- active an object
- prefab is an object
- enable a component
- any script under an object is a component
- renderer is a component
- GameObject.Find不能找被隱藏的物件/setActive(false)
二、變數在不同區域(scope)的優先權
A: 在宣告區
B: 在Start( )
C: 在Inspector (在runtime之前/在遊戲開始之前)
優先權 B > C > A
三、Awake( )與Start( )
說明:
Awake()
{
//比Start先被呼叫
//即使在Script component是關閉的狀態下,仍會呼叫Awake
}
Start()
{
//比Awake晚
//必須在Script component已經被啟動(打勾)的狀態下
}
四、Update( ) vs FixedUpdate( )
Update( )
- call every frame
- but interval time between frames is vary
- used for regular updates:
- non-physics objects movement
- simple timers
- receive input
FixedUpdate( )
- call every physics step (called in regular timeline)
- called interval time are constant
- used for adjusting physics (RB) objects
沒有留言:
張貼留言