unityscriptableobjects

A Unity ScriptableObject–specific skill that helps AI agents efficiently perform tasks related to ScriptableObject.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "unityscriptableobjects" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-459c10c9c75eb2ee41377858d2470dbcc9dc51a0421c9bcd49d2662917b20c81. Verify the upstream source and version against https://skillhub.cn/skills/user_3c6cb52e/unity-scriptableobjects-f6ns before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

A Unity ScriptableObject–specific skill that helps AI agents efficiently perform tasks related to ScriptableObject.

0 Downloads

Introduction source: third_party · user_3c6cb52e · 1.0.0 Reference

SkillPi interpretation

Tasks
Use `ScriptableObject` assets to store shared data and decouple systems in Unity 6 — configuration, event channels, and registries that live as project assets instead of being hard-wired into scenes or singletons. Targets **Unity 6 (6000.0 LTS)**.
Audience
Use when you need designer-editable config (weapon stats, level data), to share one value between unrelated systems, to decouple senders from listeners via event channels, or to build a runtime registry of active objects — without a `static`/singleton manager. Use when the project has `*.asset` data files backed by `: ScriptableObject` classes. When _not_ to use:** per-instance runtime state that differs per GameObject (that belongs on a MonoBehaviour) — a ScriptableObject asset is _shared_ by everyone who references it. Saving player progress to disk → `save-systems`. Plain DTOs that never need to be an asset can just be `[System.Serializable]` classes.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: Unityscriptableobjects
slug: unity-scriptableobjects
version: 1.0.0
displayName: Unityscriptableobjects
description: >
  UnityScriptableobjects专用技能,帮助AI Agent高效完成相关任务。
summary: "UnityScriptableobjects专用技能,帮助AI Agent高效完成相关任务。"
license: Apache-2.0
category: 游戏开发
framework:
  - Claude Code
  - Codex
  - Hermes Agent
  - OpenClaw
  - QClaw
  - WorkBuddy
platform: multi-platform
homepage: https://github.com/1991513ccie-png
repository: https://github.com/1991513ccie-png

Unity ScriptableObject Architecture

Use ScriptableObject assets to store shared data and decouple systems in Unity 6 — configuration, event channels, and registries that live as project assets instead of being hard-wired into scenes or singletons. Targets Unity 6 (6000.0 LTS).

When to use

  • Use when you need designer-editable config (weapon stats, level data), to share one value between unrelated systems, to decouple senders from listeners via event channels, or to build a runtime registry of active objects — without a static/singleton manager.
  • Use when the project has *.asset data files backed by : ScriptableObject classes.

When not to use: per-instance runtime state that differs per GameObject (that belongs on a MonoBehaviour) — a ScriptableObject asset is shared by everyone who references it. Saving player progress to disk → save-systems. Plain DTOs that never need to be an asset can just be [System.Serializable] classes.

Core workflow

  1. Define the class deriving from ScriptableObject and tag it with [CreateAssetMenu] so designers can create instances from the Assets menu.
  2. Create one or more .asset instances in the Project window; each is a shared, named piece of data referenced by [SerializeField] fields.
  3. Reference, don't copy. MonoBehaviours hold a reference to the asset; they all see the same data, so changing the asset changes every consumer.
  4. For decoupling, model signals and shared variables as ScriptableObjects: a "FloatVariable" the HUD reads and the player writes; an "event channel" the player raises and many systems listen to. Neither side references the other.
  5. Reset runtime mutations in OnEnable if the asset is mutated during play, because edits made in the Editor at runtime persist on the asset (a frequent source of "my values changed after I played").
  6. Verify by inspecting the asset values during Play mode and confirming consumers react.

Patterns

1. Config/data asset

using UnityEngine;

[CreateAssetMenu(fileName = "WeaponData", menuName = "Game/Weapon Data", order = 0)]
public class WeaponData : ScriptableObject
{
    public string displayName = "Pistol";
    public int    damage = 10;
    public float  fireRate = 0.25f;
    public GameObject projectilePrefab;
}
public class Weapon : MonoBehaviour
{
    [SerializeField] private WeaponData data;   // assign the shared asset in the Inspector
    private void Fire() => Debug.Log($"{data.displayName} for {data.damage}");
}

2. Shared runtime variable (decouples producer from consumer)

[CreateAssetMenu(menuName = "Game/Float Variable")]
public class FloatVariable : ScriptableObject
{
    [SerializeField] private float initialValue;
    [System.NonSerialized] public float runtimeValue;   // not saved to the asset

    private void OnEnable() => runtimeValue = initialValue;  // reset each play session
}
// Player writes playerHealth.runtimeValue; the HUD reads it — neither references the other.

3. Creating an instance at runtime (not an asset on disk)

// For transient SO data you build in code (e.g. a generated config).
var temp = ScriptableObject.CreateInstance<WeaponData>();
temp.damage = 25;
// ...use temp...  Destroy(temp);   // clean up runtime-created instances

Pitfalls

  • Editing an SO at runtime persists in the Editor — values you change during Play stay changed on the asset after you stop. Keep mutable runtime state in [NonSerialized] fields reset in OnEnable, or it will surprise you. (In a build, asset edits do not persist across launches.)
  • Disabled Domain Reload skips your OnEnable reset — with Enter Play Mode Options enabled and Reload Domain off (a Unity 6 fast-iteration setting), already-loaded SOs are not re-created when you press Play, so OnEnable never fires and runtimeValue keeps its value from the previous session. Reset explicitly from an ISerializationCallbackReceiver or a scene-load hook instead of relying on OnEnable alone.
  • Expecting per-object state — every reference points to the same asset. If two enemies need different current HP, store HP on the MonoBehaviour, not the shared SO.
  • No frame lifecycle — ScriptableObjects have OnEnable/OnDisable/OnDestroy but no Update. Don't expect per-frame callbacks.
  • Using SOs as a save file — they're authoring assets, not runtime persistence; write progress with save-systems instead.
  • Leaking CreateInstance objects — runtime-created instances are not garbage-collected like plain C# objects; Destroy them when done.

References

  • For the event-channel pattern (a GameEvent SO + listeners, type-safe payloads) and runtime sets/registries (a shared list of active enemies), read references/event-channels.md.
  • Primary docs: Unity Manual "ScriptableObject" (/Manual/class-ScriptableObject.html) and ScriptReference/ScriptableObject, ScriptReference/CreateAssetMenuAttribute.

Related skills

  • unity-csharp-scripting — the MonoBehaviours that consume these assets.
  • save-systems — persisting state to disk (what SOs are not for).
  • card-game / rpg / survival-crafting — genres that lean on SO-driven data.

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供 Unity 6 ScriptableObject 的完整架构指南,覆盖配置管理、事件通道、运行时变量等核心场景
  • 明确区分适用与不适用场景,帮助用户避免常见误用
Trigger Precision90/100

Highlights

  • 触发描述精准限定为 Unity ScriptableObject 专用技能,边界清晰
  • 明确指定 Unity 6 LTS 目标版本,避免版本混淆
Structure and Standards95/100

Highlights

  • 结构完整:包含 When to use、Core workflow、Patterns、Pitfalls 等标准章节
  • 提供可运行的 C# 代码示例,frontmatter 元数据齐全
Execution Reliability90/100

Highlights

  • 覆盖关键陷阱:Domain Reload 禁用时的 OnEnable 问题、运行时编辑持久化、CreateInstance 泄漏
  • 提供明确的清理机制(Destroy 运行时实例)和重置策略
Evidence Verifiability (mean of the first four)90/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • github.com

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.