unity-scenes
Skill3 starsChanged 2 months agoMITView on GitHub
Authoring reference for Unity scene files (.unity YAML) — the MCP tool workflow, the hand-edit fallback (fileID generation, PrefabInstance blocks, SceneRoots), build registration in EditorBuildSettings.asset, and the silent-null gotcha when a new [SerializeField] is added to a MonoBehaviour already placed in a scene. Load before creating, editing, registering, or debugging any .unity scene file.
In this repository45 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/issue-clarification-questions.mdcCursor rule
- .cursor/rules/reset-font-assets.mdcCursor rule
- .cursor/rules/src-dotnet-build-release.mdcCursor rule
- .cursor/rules/unity-plugins-before-work.mdcCursor rule
- codex-issueSkill
- commitSkill
- complete-prdSkill
- dependency-docsSkill
- dotnet-buildSkill
- dotnet-testSkill
- generate-imageSkill
- implementSkill
- meeting-joinSkill
- meeting-scheduleSkill
- meeting-startSkill
- plan-reviewSkill
- planSkill
- prSkill
- specifySkill
- unity-e2e-runSkill
- unity-pluginsSkill
- add-terminal-commandSkill
- dependency-docsSkill
- dotnet-benchmarkSkill
- dotnet-buildSkill
- dotnet-testSkill
- end-game-score-calibrationSkill
- flag-assetsSkill
- github-issue-automationSkill
- image-generationSkill
- localizationSkill
- meeting-joinSkill
- meeting-scheduleSkill
- meeting-startSkill
- milestone-completeSkill
- province-config-generatorSkill
- unity-e2e-runSkill
- unity-pluginsSkill
- unity-prefabsSkill
- update-branchSkill
- cursor-meeting-joinSkill
- cursor-meeting-startSkill
- unity-pluginsSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 27
Prefab instances in a scene: use !u!1001 PrefabInstance blocks:
- Distinctive: line 55
When Unity Editor is connected via UnityMCP, use MCP tools instead of hand-editing YAML:
- Very specific: line 74
Every object in a scene needs a unique positive integer fileID.
- Very specific: line 131
Add {fileID: <new-fileID>} to SceneRoots.m_Roots.
- Very specific: line 145
Add the Transform fileID to SceneRoots.m_Roots for root objects
- Very specific: line 153
Delete its PrefabInstance block and remove its fileID from SceneRoots.m_Roots.
- Very specific: line 172
When a [SerializeField] field is added to a C# class that is already instantiated in a scene, Unity does not auto-populate the field in the …
- Distinctive: line 188
Always verify by searching the scene YAML for the field name before assuming it is assigned.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Scene Format and Registration
File Format
Scene files (.unity) are Unity YAML files (%YAML 1.1). They must be created through the Unity Editor. Structure:
Fixed header objects (always present, fileIDs 1–4):
!u!29 &1— OcclusionCullingSettings!u!104 &2— RenderSettings!u!157 &3— LightmapSettings!u!196 &4— NavMeshSettings
Scene content — GameObjects, components, and prefab instances with large random fileIDs.
Prefab instances in a scene use !u!1001 PrefabInstance blocks:
--- !u!1001 &<fileID>
PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0} # 0 = root; or fileID of parent Transform
m_Modifications:
- target: {fileID: <obj-fileID>, guid: <prefab-guid>, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: <prefab-guid>, type: 3}SceneRoots (always the last object, fileID 9223372036854775807) lists the fileIDs of all root-level Transform/PrefabInstance objects:
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_Roots:
- {fileID: <transform-or-prefabinstance-fileID>}MCP Workflow (preferred)
When Unity Editor is connected via UnityMCP, use MCP tools instead of hand-editing YAML:
- Inspect scene:
manage_scene(actionget_hierarchy) ormcpforunity://scene/gameobject-api - Add prefab instance:
manage_gameobject(actioncreate, paramprefab_path) - Add plain GameObject:
manage_gameobject(actioncreate) - Modify object:
manage_gameobject(actionmodify) ormanage_components(actionset_property) - Remove object:
manage_gameobject(actiondelete) - Save scene:
manage_scene(actionsave)
Scene registration in EditorBuildSettings.asset has no MCP tool — edit that file directly (see Scene Registration section below).
Fall back to the manual YAML workflow below only when MCP is unavailable.
Modifying Scenes via Text
Scene files can be modified by hand if the rules below are followed precisely.
FileID generation
Every object in a scene needs a unique positive integer fileID. When adding new objects, pick a large random integer (e.g. 9 digits) that does not collide with any existing &fileID anchor in the file. FileIDs 1–4 are reserved for the header objects.
Adding a prefab instance
- Get the prefab's GUID from its
.metafile. - Get the fileIDs of the prefab's internal objects from the
.prefabfile (needed form_Modificationstargets). - Choose a new unique fileID for the
PrefabInstanceblock. - Append the block before
SceneRoots:
--- !u!1001 &<new-fileID>
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: <root-transform-fileID-in-prefab>, guid: <prefab-guid>, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: <root-transform-fileID-in-prefab>, guid: <prefab-guid>, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: <root-transform-fileID-in-prefab>, guid: <prefab-guid>, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: <root-transform-fileID-in-prefab>, guid: <prefab-guid>, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: <root-transform-fileID-in-prefab>, guid: <prefab-guid>, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: <root-transform-fileID-in-prefab>, guid: <prefab-guid>, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: <root-transform-fileID-in-prefab>, guid: <prefab-guid>, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: <root-gameobject-fileID-in-prefab>, guid: <prefab-guid>, type: 3}
propertyPath: m_Name
value: MyInstance
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: <prefab-guid>, type: 3}- Add
{fileID: <new-fileID>}toSceneRoots.m_Roots.
To set position to something other than origin, change the value fields for m_LocalPosition.*.
To override a serialized field on a component inside the prefab, add a m_Modifications entry pointing to that component's fileID and propertyPath matching the C# field name.
To parent the instance under another GameObject's Transform, set m_TransformParent: {fileID: <parent-transform-fileID>} and do not add it to SceneRoots.
Adding a plain GameObject
Requires three blocks: GameObject (!u!1), Transform (!u!4), and any components. Each gets its own unique fileID. Cross-references:
GameObject.m_Componentlists all component fileIDsTransform.m_GameObjectpoints to its GameObjectTransform.m_Father: {fileID: 0}for root objects- Add the Transform fileID to
SceneRoots.m_Rootsfor root objects
Modifying an existing object
Edit the value directly in the relevant block. For prefab instances, only change value fields inside m_Modifications — do not change target.fileID or target.guid.
Removing a prefab instance
Delete its PrefabInstance block and remove its fileID from SceneRoots.m_Roots.
Scene Registration
To include a scene in the build, add it to ProjectSettings/EditorBuildSettings.asset:
m_Scenes:
- enabled: 1
path: Assets/Scenes/Feature/SceneName.unity
guid: <scene-guid>guidcomes from the scene's.metafile (guid:field)- Scenes not listed here are excluded from builds (but can still be loaded by path in the Editor)
- Order in
m_Scenesdetermines the build index used bySceneManager.LoadScene(int)
New [SerializeField] fields on existing scene MonoBehaviours
When a [SerializeField] field is added to a C# class that is already instantiated in a scene, Unity does not auto-populate the field in the scene YAML. It stays absent, which means the field is null/default at runtime — silently, with no error.
To wire it up without opening the Unity Editor, add the field line directly to the MonoBehaviour block in the .unity YAML:
--- !u!114 &<fileID>
MonoBehaviour:
...
_existingField: {fileID: 4900000, guid: <existing-guid>, type: 3}
_newField: {fileID: 4900000, guid: <new-asset-guid>, type: 3} # add thisfileID: 4900000is the standard fileID forTextAssetreferencestype: 3means a regular imported asset- The guid comes from the asset's
.metafile
Always verify by searching the scene YAML for the field name before assuming it is assigned.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

