Hi, I have a class that derives from UnityEngine.UI.Button
And my CustomEditor class derives from UnityEditor.UI.ButtonEditor.
My problem is that when I call ApplyModifiedProperties() all my custom variables are saved while the standard button variables are lost.
I’ve noticed that if I DON’T call ApplyModifiedProperties() all standard variables are saved while mine are lost.
[CustomEditor(typeof(CustomButton), true)]
public class CustomButton_Editor : ButtonEditor
{
private SerializedObject m_Object;
private SerializedProperty m_Property;
protected override void OnEnable()
{
m_Object = new SerializedObject(target);
base.OnEnable();
}
public override void OnInspectorGUI()
{
...
...
m_Property = m_Object.FindProperty("_scaleTo");
EditorGUILayout.PropertyField(m_Property, new GUIContent(m_Property.displayName, m_Property.tooltip));
base.OnInspectorGUI();
m_Property = m_Object.FindProperty("_triggerDirectly");
EditorGUILayout.PropertyField(m_Property, new GUIContent(m_Property.displayName, m_Property.tooltip));
if (GUI.changed)
{
m_Object.ApplyModifiedProperties();
}
}
}
I’m using Unity version: 5.3.3p1
So does anyone have any idea how to solve this?
Thank you.