CustomEditor Inheritance Issue
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.
Answer by Silve · Mar 15, 2016 at 04:29 PM
I found the solution, I had to add m_Object.Update(); after m_Object.ApplyModifiedProperties(); (line 28)
Your answer
Follow this Question
Related Questions
Unity Custom Editor: 1 True Bool Only Within A Group 1 Answer
Custom inspector Vs. Custom window 2 Answers
Use placeholder text in CustomEditor 0 Answers
No type in ObjectField created in uxml (UIElements) 3 Answers
How can I modify 'SerializedProperty' that contain 'Array' in Custom inspector? 0 Answers