Intended as a diff driver textconv filter for Unity YAML files (*.unity, *.prefab, etc.)
Diffs of Unity's scene files are hard to understand at a glance, since we lack a lot of context from other parts of the file, like where in the hierarchy the object, whose property we are viewing, is. Things like components types and GameObject names are also obscured:
(...)
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &8647582166906343228
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9174457899731291163}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 921cbab55b5bd5f4196341132c8f5eca, type: 3}
m_Name:
m_EditorClassIdentifier:
_colors:
- {r: 0.972549, g: 0.7, b: 0.8, a: 1}
- {r: 0.105882354, g: 0.4, b: 0.7, a: 1}
- {r: 0.627451, g: 0.9, b: 0.9, a: 1}
(...)
After installing unity2text as a textconv filter for the repo, the diff output has much more context:
(...)
House 1/Wall.SpriteRenderer: m_WasSpriteAssigned: 1
House 1/Wall.SpriteRenderer: m_MaskInteraction: 0
House 1/Wall.SpriteRenderer: m_SpriteSortPoint: 0
House 1/Wall.SetRandomSpriteColor.cs: MonoBehaviour:
House 1/Wall.SetRandomSpriteColor.cs: m_ObjectHideFlags: 0
House 1/Wall.SetRandomSpriteColor.cs: m_CorrespondingSourceObject: (None)
House 1/Wall.SetRandomSpriteColor.cs: m_PrefabInstance: (None)
House 1/Wall.SetRandomSpriteColor.cs: m_PrefabAsset: (None)
House 1/Wall.SetRandomSpriteColor.cs: m_GameObject: House 1/Wall.GameObject
House 1/Wall.SetRandomSpriteColor.cs: m_Enabled: 1
House 1/Wall.SetRandomSpriteColor.cs: m_EditorHideFlags: 0
House 1/Wall.SetRandomSpriteColor.cs: m_Script: fileID: 11500000 in SetRandomSpriteColor.cs
House 1/Wall.SetRandomSpriteColor.cs: m_Name:
House 1/Wall.SetRandomSpriteColor.cs: m_EditorClassIdentifier:
House 1/Wall.SetRandomSpriteColor.cs: _colors:
House 1/Wall.SetRandomSpriteColor.cs: - {r: 0.9, g: 0.7, b: 0.8, a: 1}
House 1/Wall.SetRandomSpriteColor.cs: - {r: 0.1, g: 0.4, b: 0.7, a: 1}
House 1/Wall.SetRandomSpriteColor.cs: - {r: 0.6, g: 0.9, b: 0.9, a: 1}
(...)
unity2text works by parsing the scene file so it can insert more human-readable names when encountering various cross-references in the file.
It can optionally build and cache a map of script GUIDs and names, so you can see what script a modified property was associated with.
Note: This not feature complete. Some things, like prefab instances are not handled correctly (yet). It is also more a proof of concept than anything, so use it at your own risk.
It can be "installed" on a repository (see how below). You can also uninstall it as well as temporarily deactivate it when needed.
Usage: unity2text <asset_file>
unity2text <option>
Options:
-r, --rebuild-lookup
Builds a lookup of asset GUIDs to names and saves it in .git/unity2text/lookup.
This improves the output when converting Unity assets, by converting GUIDs to names.
-i, --install
Installs this as a git diff driver in the current repo.
This will:
- add 'diff=unity' to an internal gitattributes file (.git/unity2text/attributes) for common Unity assets and
- add this file to the setting 'core.attributesfile' in the local git config (.git/config)
- add 'diff.unity.textconv=unity2text' in the local git config (.git/config)
-u, --uninstall
Uninstalls this from the current repo, essentially reverting what --install does
-a, --activate
Like --install, except it only changes the git config. Can be used to re-enable the diff driver after a --deactivate
-d, --deactivate
Like --uninstall, except it only changes the git config. Useful if you want to disable the diff driver temporarily,
but don't want to lose the lookup generated by --rebuild-lookup.
-h, --help
Shows this help message.
https://blog.unity.com/engine-platform/understanding-unitys-serialization-language-yaml