Skip to content

Mark Object as Dirty In Drawer#2

Closed
sim2kid wants to merge 1 commit into
Sterberino:mainfrom
sim2kid:main
Closed

Mark Object as Dirty In Drawer#2
sim2kid wants to merge 1 commit into
Sterberino:mainfrom
sim2kid:main

Conversation

@sim2kid
Copy link
Copy Markdown

@sim2kid sim2kid commented Aug 23, 2024

The DictionaryDrawer has been given a MarkDirty method to run after the internal dictionary is modified. When the modification occurs, the serialized target object is marked as dirty, so Unity knows it needs to be reserialized/saved.

This also adds a tracked UnityObject named trackedObject so that the SerializedProperty does not need to be passed to each method. As such, the trackedObject is set in the CheckInitialize function and is cleared at the returns of the OnGUI functions.

To mark the object as dirty, the EditorUtility.SetDirty method is ran. This will mark the object as modified. Similarly, for prefab overrides, the PrefabUtility.RecordPrefabInstancePropertyModifications is ran.
See more details on these methods in the Unity Documentation.

This does explicitly not use the Undo.RecordObject method and bypasses the undo tree. It did not work when using this method instead of thew SetDirty one.

This addresses issue #1.

The DictionaryDrawer has been given a MarkDirty method to run after the internal dictionary is modified. When the modification occurs, the serialized target object is marked as dirty, so Unity knows it needs to be reserialized/saved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant