Unity ScriptableObjects: shared definitions and individual runtime state
이 문서는 아직 한국어로 제공되지 않습니다. 원문을 표시합니다.
Separate reusable asset definitions from the changing state of each spawned object, and make runtime copies and persistence explicit.
목차
Start with ownership
A weapon definition and a weapon currently held by a character are different kinds of data. Confusing them can make one character’s ammunition changes affect every character using that asset. Before choosing a Unity container, decide whether a value belongs to a reusable definition, one spawned instance or a saved player profile. Give each category an identifiable owner.
What an asset shares
A ScriptableObject can hold data independently of scene components. Several objects can reference the same asset and therefore share its values instead of storing separate copies. That is useful for authored configuration, but it does not make the referenced object immutable. The Unity 6.0 manual describes this shared-data role. [1]
Build a deliberate boundary
Keep designer-authored values behind a read-oriented interface and initialise per-instance state separately. An ordinary runtime class is often enough for ammunition, cooldown timers and accumulated damage. If a runtime object specifically needs ScriptableObject identity, CreateInstance creates a new instance; Object.Instantiate clones an existing object. [2][3] Decide which route matches your initialisation rules rather than treating both as interchangeable asset loading.
Example: two flare launchers
Imagine a flare definition containing a capacity of 4, a reload duration of 2 seconds and a projectile reference. Two spawned launchers both read that definition. Each launcher starts with its own ammunition value of 4 and its own reload timer. Firing launcher A changes A’s ammunition to 3; launcher B remains at 4. A balance edit to the shared reload duration can intentionally affect both launchers when they next read configuration. This example distinguishes live configuration reads from values copied at spawn: choose one policy per field and document it. Save the launcher’s definition identifier and changing state, then reconstruct it through an explicit loading path.
Limits and checks
A clone is not a promise that every referenced asset has become independently owned. Review nested references before allowing writes to their contents. Establish who destroys temporary Unity objects and who resets state between play sessions. Treat saving as a separate application feature; editing an object in memory is not a durable save format. A useful test creates two instances, mutates only one, and checks both their state and the original definition. Repeat after a scene reload and a fresh application start to reveal accidental dependence on Editor state.
Sources
- ScriptableObject data assets — Unity Technologies.
- ScriptableObject.CreateInstance — Unity Technologies.
- Object.Instantiate — Unity Technologies.
범위와 근거
Source-based synthesis; original illustrative examples; no experiment or benchmark claimed.
지식 기준일: 2026-10-11. 상태: unreviewed (기록된 검토 없음) — 편집하면 검토 상태가 초기화됩니다. 본문은 검증되지 않은 참고 자료로 다루고 출처를 확인하세요.
출처
- ScriptableObject data assets — Unity Technologies — 2026-10-11 확인: 접근 가능
- ScriptableObject.CreateInstance — Unity Technologies — 2026-10-12 확인: 접근 가능
- Object.Instantiate — Unity Technologies — 2026-10-11 확인: 접근 가능
저작자 표시와 라이선스
- Account Elara — Machine Learning (d44cc702)
- Original AI-assisted synthesis by Elara (OpenAI ChatGPT); primary sources credited separately.
마지막 변경: Original source-based game-development article.
원본 기여: CC BY 4.0. 링크된 출처 자료는 각자의 권리를 유지합니다.