{"id":13658302,"url":"https://github.com/socialpoint-labs/unity-yaml-parser","last_synced_at":"2025-12-14T05:05:38.795Z","repository":{"id":34934638,"uuid":"190599724","full_name":"socialpoint-labs/unity-yaml-parser","owner":"socialpoint-labs","description":"Python3 library to manipulate Unity serialized files from outside the Unity Editor.","archived":false,"fork":false,"pushed_at":"2025-02-27T07:36:16.000Z","size":167,"stargazers_count":155,"open_issues_count":13,"forks_count":27,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-23T11:41:57.768Z","etag":null,"topics":["python-library","pyyaml","unity","unity-yamls"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/unityparser/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/socialpoint-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-06T14:54:10.000Z","updated_at":"2025-03-31T14:08:02.000Z","dependencies_parsed_at":"2024-01-14T17:05:45.235Z","dependency_job_id":"eb34bd92-29d3-4937-8e66-2e65a4111b79","html_url":"https://github.com/socialpoint-labs/unity-yaml-parser","commit_stats":{"total_commits":83,"total_committers":5,"mean_commits":16.6,"dds":"0.24096385542168675","last_synced_commit":"545c27ef55dc567c5a1d36bc50886ce4afe816a5"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socialpoint-labs%2Funity-yaml-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socialpoint-labs%2Funity-yaml-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socialpoint-labs%2Funity-yaml-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socialpoint-labs%2Funity-yaml-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/socialpoint-labs","download_url":"https://codeload.github.com/socialpoint-labs/unity-yaml-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250592077,"owners_count":21455496,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python-library","pyyaml","unity","unity-yamls"],"created_at":"2024-08-02T05:00:58.462Z","updated_at":"2025-12-14T05:05:33.738Z","avatar_url":"https://github.com/socialpoint-labs.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Unity YAML Parser #\n\nThis project aims to provide a python3 API to load and dump [Unity YAML \nfiles](https://docs.unity3d.com/Manual/TextSceneFormat.html) (configurations, prefabs, scenes, serialized data, etc) in the exact same \nformat the internal Unity YAML serializer does.\n\nUsing this API you will be able to easily manipulate(as python objects) \nUnity YAML files and save them just the same, keeping the YAML structure\nexactly as Unity does. This has the advantages of, first not having to\nconfigure PyYAML beforehand to deal with Unity YAMLs, and second as the\nmodified file keeps the same structure and formatting that Unity does, \nwhen the YAML file is loaded by Unity it won't make formatting changes \nto it that will make any VCS report unexpected file changes.\n\n## Installing ##\n\nInstall and update using [pip](https://pip.pypa.io/en/stable/quickstart/):\n````\npip install -U unityparser\n````\n## A Simple Example ##\n````python\nfrom unityparser import UnityDocument\n\n# Loading and modifying a config file with a single YAML document\nproject_settings_file = 'UnityProject/ProjectSettings/ProjectSettings.asset'\ndoc = UnityDocument.load_yaml(project_settings_file)\nProjectSettings = doc.entry\nProjectSettings.scriptingDefineSymbols[1] += ';CUSTOM_DEFINE'\nProjectSettings.scriptingDefineSymbols[7] = ProjectSettings.scriptingDefineSymbols[1]\ndoc.dump_yaml()\n\n# You can also load YAML files with multiple documents and filter for a single or multiple entries\nhero_prefab_file = 'UnityProject/Assets/Prefabs/Hero.prefab'\ndoc = UnityDocument.load_yaml(hero_prefab_file)\n# accessing all entries\ndoc.entries\n# [\u003cUnityClass\u003e, \u003cUnityClass\u003e, ...]\n# accessing first entry\ndoc.entry\n# \u003cUnityClass\u003e\n# get single entry uniquely defined by filters\nentry = doc.get(class_name='MonoBehaviour', attributes=('m_MaxHealth',))\nentry.m_MaxHealth += 10\n# get multiple entries matching a filter\nentries = doc.filter(class_names=('MonoBehaviour',), attributes=('m_Enabled',))\nfor entry in entries:\n    entry.m_Enabled = 1\ndoc.dump_yaml()\n# calling entry method for a doc with multiple document will return the first one\nprint(doc.entry.__class__.__name__)\n# 'Prefab'\n\n# get the object ID number\n# e.g., the first line of an object == '--- !u!1 \u002642362281700597288'\nprint(doc.entry.anchor)  \n# '42362281700597288' \n````\n\n## Classes ##\n\n### unityparser.UnityDocument ###\n\nMain class to load and dump files.\n\n#### unityparser.UnityDocument.load_yaml(file_path) ####\n\n_**Classmethod**_: Load the given YAML file_path and return a UnityDocument file\n\n#### unityparser.UnityDocument.dump_yaml(file_path=None) ####\n\nDump the UnityDocument to the previously loaded file location(overwrite). \nIf *file_path* argument is provided, dump the document to the specified location instead.\n\nThis method **keeps line endings** of the original file when it dumps.\n\n#### unityparser.UnityDocument.entries ####\n\n_**Property**_: Return the _list_ of documents found in the YAML. The objects in the _list_ are of _types_ Class named after the serialized Unity class(ie. MonoBehaviour, GameObject, Prefab, CustomName, etc).\n\n#### unityparser.UnityDocument.entry ####\n\n_**Property**_: Return the first document in the YAML, useful if there is only one. Equivalent of doing `UnityDocument.entries[0]`.\n\n#### unityparser.UnityDocument.get(class_name=None, attributes=None) ####\n\n_**Method**_: Return a single entry uniquely matching the given filters. Must exist exactly one.\n\n#### unityparser.UnityDocument.filter(class_names=None, attributes=None) ####\n\n_**Method**_: Return a list of entries matching the given filters. Many or none can be matched.\n\n### unityparser.loader.UnityLoader ###\n\nPyYAML's Loader class, can be used directly with PyYAML to customise loading. \n\n### unityparser.dumper.UnityDumper ###\n\nPyYAML's Dumper class, can be used directly with PyYAML to customise dumping. \n\n## Considerations ##\n\nText scalars which are single or double quoted that span multiple lines are not being dumped exactly as Unity does. There's a difference in the maximum length allowed per line and the logic to wrap them.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocialpoint-labs%2Funity-yaml-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsocialpoint-labs%2Funity-yaml-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocialpoint-labs%2Funity-yaml-parser/lists"}