Add value modification tracking

This commit is contained in:
VladV 2022-05-11 11:54:19 +03:00
parent ac5c8b6792
commit bdc01494ee
6 changed files with 35 additions and 8 deletions

View File

@ -66,7 +66,14 @@ namespace TriInspector.Drawers
public override void OnGUI(Rect position)
{
EditorGUI.BeginChangeCheck();
EditorGUI.PropertyField(position, _serializedProperty, _property.DisplayNameContent);
if (EditorGUI.EndChangeCheck())
{
_property.NotifyValueChanged();
}
}
}
}

View File

@ -27,7 +27,14 @@ namespace TriInspector.Elements
public override void OnGUI(Rect position)
{
EditorGUI.BeginChangeCheck();
_propertyHandler.OnGUI(position, _serializedProperty, _property.DisplayNameContent, true);
if (EditorGUI.EndChangeCheck())
{
_property.NotifyValueChanged();
}
}
}
}

View File

@ -122,6 +122,7 @@ namespace TriInspector.Elements
if (_property.TryGetSerializedProperty(out _))
{
ReorderableList.defaultBehaviours.DoAddButton(reorderableList);
_property.NotifyValueChanged();
return;
}
@ -157,6 +158,7 @@ namespace TriInspector.Elements
if (_property.TryGetSerializedProperty(out _))
{
ReorderableList.defaultBehaviours.DoRemoveButton(reorderableList);
_property.NotifyValueChanged();
return;
}
@ -187,6 +189,7 @@ namespace TriInspector.Elements
{
if (_property.TryGetSerializedProperty(out _))
{
_property.NotifyValueChanged();
return;
}

View File

@ -67,8 +67,6 @@ namespace TriInspector
{
Profiler.EndSample();
}
EditorGUI.BeginChangeCheck();
EditorStack.Push(this);
Profiler.BeginSample("TriInspector.DoLayout()");
@ -82,11 +80,6 @@ namespace TriInspector
EditorStack.Pop();
}
if (EditorGUI.EndChangeCheck())
{
_inspector.RequestValidation();
}
if (serializedObject.ApplyModifiedProperties())
{
_inspector.RequestValidation();

View File

@ -267,7 +267,17 @@ namespace TriInspector
PropertyTree.ForceUpdateSerializedObject();
Update();
PropertyTree.RequestValidation();
NotifyValueChanged();
}
public void NotifyValueChanged()
{
((ITriPropertyParent) this).NotifyValueChanged(this);
}
void ITriPropertyParent.NotifyValueChanged(TriProperty property)
{
_parent.NotifyValueChanged(property);
}
internal void Update()
@ -561,6 +571,8 @@ namespace TriInspector
public interface ITriPropertyParent
{
object GetValue(int targetIndex);
void NotifyValueChanged(TriProperty property);
}
public enum TriPropertyType

View File

@ -116,6 +116,11 @@ namespace TriInspector
}
}
public void NotifyValueChanged(TriProperty property)
{
RequestValidation();
}
public void RequestRepaint()
{
RepaintRequired = true;