socialpoint-labs / unity-yaml-parser

Python3 library to manipulate Unity serialized files from outside the Unity Editor.
https://pypi.org/project/unityparser/
MIT License
137 stars 24 forks source link

dump_yaml does not dump new attributes you have added to a settings file #63

Open NurullahMorshed opened 1 year ago

NurullahMorshed commented 1 year ago

I am trying to manipulate the settings files for my CI pipeline. I can modify settings that already exist, but when I try to load a new setting attribute, it lets me add it to the entry, but when I run dum_yaml command, only settings attributes that already exist are changed. The new settings I have added are not in the file.

Specifically, I am manipulating the IL2CPP settings and trying to protect against a situation where someone has not enabled il2cpp and is missing the settings in the project settings file.

Steps to reproduce:

  1. project_settings_file = 'UnityProject/ProjectSettings/ProjectSettings.asset'
  2. doc = UnityDocument.load_yaml(project_settings_file)
  3. ProjectSettings = doc.entry
  4. ProjectSettings.testAttribute = {}
  5. ProjectSettings.testAttribute
  6. ProjectSettings.testAttribute["Test"] = "1"
  7. ProjectSettings.testAttribute["Test"]
  8. doc.dump_yaml()
  9. Open ProjectSettings file

Expected Results: Project settings file has a new entry called testAttribute with a value of Test = 1