#179 - Fixes to AtomDrawer + FSM editor

This commit is contained in:
Adam Ramberg 2020-08-04 00:59:22 +02:00
parent cd8cd63ec0
commit 0540add7b8
3 changed files with 13 additions and 11 deletions

View File

@ -86,7 +86,13 @@ namespace UnityAtoms.Editor
}
else
{
property.objectReferenceValue = EditorGUI.ObjectField(position, property.objectReferenceValue, typeof(T), false);
EditorGUI.BeginChangeCheck();
var obj = EditorGUI.ObjectField(position, property.objectReferenceValue, typeof(T), false);
if (EditorGUI.EndChangeCheck())
{
property.objectReferenceValue = obj;
}
}
if (property.objectReferenceValue == null)

View File

@ -17,7 +17,6 @@ namespace UnityAtoms.Editor
{
serializedObject.Update();
bool valueWasUpdated = false;
EditorGUILayout.PropertyField(serializedObject.FindProperty("_developerDescription"));
EditorGUILayout.Space();
@ -61,7 +60,7 @@ namespace UnityAtoms.Editor
var value = serializedObject.FindProperty("_value").GetGenericPropertyValue(JsonUtility.FromJson<T>(JsonUtility.ToJson(atomTarget.BaseValue)));
atomTarget.BaseValue = value;
}
valueWasUpdated = true;
serializedObject.Update();
}
}
@ -114,10 +113,7 @@ namespace UnityAtoms.Editor
EditorGUILayout.PropertyField(serializedObject.FindProperty("_triggerChangedWithHistoryOnOnEnable"), new GUIContent("ChangedWithHistory"));
}
if (!valueWasUpdated)
{
serializedObject.ApplyModifiedProperties();
}
serializedObject.ApplyModifiedProperties();
}
}
}

View File

@ -37,8 +37,8 @@ namespace UnityAtoms.FSM.Editor
const int raiseButtonWidth = 52;
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("Changed"));
var changed = serializedObject.FindProperty("Changed").objectReferenceValue;
EditorGUILayout.PropertyField(serializedObject.FindProperty("_changed"));
var changed = serializedObject.FindProperty("_changed").objectReferenceValue;
if (changed != null && changed is AtomEventBase evt && target is AtomBaseVariable atomTarget)
{
GUILayout.Space(2);
@ -52,8 +52,8 @@ namespace UnityAtoms.FSM.Editor
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("ChangedWithHistory"));
var changedWithHistory = serializedObject.FindProperty("ChangedWithHistory").objectReferenceValue;
EditorGUILayout.PropertyField(serializedObject.FindProperty("_changedWithHistory"));
var changedWithHistory = serializedObject.FindProperty("_changedWithHistory").objectReferenceValue;
if (changedWithHistory != null && changedWithHistory is AtomEventBase evt && target is AtomBaseVariable atomTarget)
{