From c8c215abfd10bcca29d585b0370dd485136a56d1 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 6 Apr 2021 15:47:00 +0200 Subject: [PATCH] Add support for custom value propagation in CustomEditor --- Source/Editor/CustomEditors/CustomEditor.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/Editor/CustomEditors/CustomEditor.cs b/Source/Editor/CustomEditors/CustomEditor.cs index c5c628755..ca45652b9 100644 --- a/Source/Editor/CustomEditors/CustomEditor.cs +++ b/Source/Editor/CustomEditors/CustomEditor.cs @@ -250,6 +250,15 @@ namespace FlaxEditor.CustomEditors _children[i].RefreshInternal(); } + /// + /// Synchronizes the value of the container. Called during Refresh to flush property after editing it in UI. + /// + /// The value to set. + protected virtual void SynchronizeValue(object value) + { + _values.Set(_parent.Values, value); + } + internal virtual void RefreshInternal() { if (_values == null) @@ -264,7 +273,7 @@ namespace FlaxEditor.CustomEditors _valueToSet = null; // Assign value - _values.Set(_parent.Values, val); + SynchronizeValue(val); // Propagate values up (eg. when member of structure gets modified, also structure should be updated as a part of the other object) var obj = _parent;