Unity
Installation
SKILL.md
Lifecycle Order
AwakebeforeStart— use Awake for self-init, Start for cross-referencesOnEnablecalled beforeStart— but afterAwake- Order between scripts not guaranteed — use Script Execution Order if needed
Awakecalled even if disabled —Startonly when enabled
GetComponent Performance
GetComponentevery frame is slow — cache inAwakeorStartGetComponentInChildrensearches recursively — expensive on deep hierarchiesTryGetComponentreturns bool — avoids null check, slightly faster- Use
RequireComponentattribute — ensures dependency, documents requirement
Physics Timing
- Physics in
FixedUpdate, notUpdate— consistent regardless of framerate FixedUpdatecan run 0 or multiple times per frame — don't assume 1:1Rigidbody.MovePositionin FixedUpdate —transform.positionbypasses physicsTime.deltaTimein Update,Time.fixedDeltaTimein FixedUpdate — or just use deltaTime