Add support for custom value propagation in CustomEditor

This commit is contained in:
Wojtek Figat
2021-04-06 15:47:00 +02:00
parent 2d6f8cc406
commit c8c215abfd

View File

@@ -250,6 +250,15 @@ namespace FlaxEditor.CustomEditors
_children[i].RefreshInternal(); _children[i].RefreshInternal();
} }
/// <summary>
/// Synchronizes the value of the <see cref="Values"/> container. Called during Refresh to flush property after editing it in UI.
/// </summary>
/// <param name="value">The value to set.</param>
protected virtual void SynchronizeValue(object value)
{
_values.Set(_parent.Values, value);
}
internal virtual void RefreshInternal() internal virtual void RefreshInternal()
{ {
if (_values == null) if (_values == null)
@@ -264,7 +273,7 @@ namespace FlaxEditor.CustomEditors
_valueToSet = null; _valueToSet = null;
// Assign value // 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) // 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; var obj = _parent;