Skip to content

Mark Object as Dirty In Drawer#3

Open
sim2kid wants to merge 1 commit into
Sterberino:mainfrom
sim2kid:bug/dirty-object
Open

Mark Object as Dirty In Drawer#3
sim2kid wants to merge 1 commit into
Sterberino:mainfrom
sim2kid:bug/dirty-object

Conversation

@sim2kid
Copy link
Copy Markdown

@sim2kid sim2kid commented Aug 29, 2024

Note: This is a remake of #2 so that I can continue to iterate on my own repo.

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