Unity

v1.0.0

Avoid common Unity mistakes — lifecycle ordering, GetComponent caching, physics timing, and Unity's fake null.

3· 1.7k·11 current·11 all-time
byIván@ivangdavila
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
The name/description promise Unity coding guidance and the SKILL.md is purely that: a checklist of Unity lifecycle, performance, physics, serialization, and coroutine tips. It requests no binaries, env vars, or config paths that would be unrelated to providing documentation-like guidance.
Instruction Scope
The runtime instructions are static prose with actionable advice for Unity developers. They do not instruct the agent to read files, call external endpoints, access environment variables, or perform system operations beyond presenting text—no scope creep detected.
Install Mechanism
There is no install spec and no code files. As an instruction-only skill, it writes nothing to disk and has a minimal footprint.
Credentials
The skill requires no environment variables, credentials, or config paths. The lack of requested secrets is proportional to its documentation-style purpose.
Persistence & Privilege
always is false and the skill does not ask for persistent permissions or modify other skills/config. Autonomous invocation is allowed by default but, given the skill's instruction-only nature and lack of requested privileges, this does not create a meaningful risk.
Assessment
This skill is essentially a static tipsheet for Unity development and doesn’t request any credentials, installs, or filesystem access—so it’s low-risk and coherent with its description. Before installing, consider: (1) the content has no provenance or links to authoritative sources—treat it as general guidance and verify critical recommendations against Unity docs, (2) if future versions add install steps, downloads, or env-var requirements, re-check those changes before accepting them, and (3) be cautious about following code suggestions verbatim in production projects without review or testing.

Like a lobster shell, security has layers — review code before you run it.

Runtime requirements

🎮 Clawdis
OSLinux · macOS · Windows
latestvk97arcwcway0fy0zqrk1dq810180wha6
1.7kdownloads
3stars
1versions
Updated 1mo ago
v1.0.0
MIT-0
Linux, macOS, Windows

Lifecycle Order

  • Awake before Start — use Awake for self-init, Start for cross-references
  • OnEnable called before Start — but after Awake
  • Order between scripts not guaranteed — use Script Execution Order if needed
  • Awake called even if disabled — Start only when enabled

GetComponent Performance

  • GetComponent every frame is slow — cache in Awake or Start
  • GetComponentInChildren searches recursively — expensive on deep hierarchies
  • TryGetComponent returns bool — avoids null check, slightly faster
  • Use RequireComponent attribute — ensures dependency, documents requirement

Physics Timing

  • Physics in FixedUpdate, not Update — consistent regardless of framerate
  • FixedUpdate can run 0 or multiple times per frame — don't assume 1:1
  • Rigidbody.MovePosition in FixedUpdate — transform.position bypasses physics
  • Time.deltaTime in Update, Time.fixedDeltaTime in FixedUpdate — or just use deltaTime

Unity's Fake Null

  • Destroyed objects aren't truly null — == null returns true, but object exists
  • Null-conditional ?. doesn't work properly — use == null or bool conversion
  • Destroy doesn't happen immediately — object gone next frame
  • Use DestroyImmediate only in editor — causes issues in builds

Coroutines

  • StartCoroutine needs MonoBehaviour active — disabled/destroyed stops coroutines
  • yield return null waits one frame — yield return new WaitForSeconds(1) for time
  • StopCoroutine needs same method or Coroutine reference — string overload unreliable
  • Can't return values — use callbacks or set field in coroutine

Instantiate and Pooling

  • Instantiate is expensive — pool frequently created/destroyed objects
  • Instantiate(prefab, parent) sets parent — avoids extra SetParent call
  • SetActive(false) before returning to pool — not Destroy
  • Pool inactive objects under a parent — keeps hierarchy clean

Serialization

  • [SerializeField] for private fields in inspector — prefer over public
  • public fields auto-serialize — but exposes API you may not want
  • [HideInInspector] hides but still serializes — [NonSerialized] to skip entirely
  • Serialized fields keep inspector values — code defaults ignored after first serialize

ScriptableObjects

  • Data containers that live as assets — share between scenes/prefabs
  • CreateAssetMenu attribute for easy creation — right-click → Create
  • Don't modify at runtime in builds — changes not saved (except in editor)
  • Great for config, item databases — reduces prefab duplication

Common Mistakes

  • Find methods every frame — cache references
  • String comparisons for tags — use CompareTag("Enemy"), not tag == "Enemy"
  • Physics queries allocate — use NonAlloc variants: RaycastNonAlloc
  • UI anchors wrong — stretches unexpectedly on different resolutions
  • async/await without context — use UniTask or careful error handling

Comments

Loading comments...