I made a video to show one of the things I am stuck on! please watch!
Thank you in advance
The editor redraws constantly. Take the code out of the change check and evaluate the enumValueIndex of the seriallized property.
Like so;
using UnityEngine;
public class EditorEnum : MonoBehaviour
{
public enum MyEnums
{
Value0,
Value1,
Value2
}
public MyEnums MyEnum;
}
using UnityEditor;
[CustomEditor(typeof(EditorEnum))]
public class EditorEnumEditor : Editor
{
private SerializedProperty _enum;
private void OnEnable()
{
_enum = serializedObject.FindProperty("MyEnum");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(_enum);
switch (_enum.enumValueIndex)
{
case 0:
EditorGUILayout.LabelField("Value is 0");
break;
case 1:
EditorGUILayout.LabelField("Value is 1");
break;
case 2:
EditorGUILayout.LabelField("Value is 2");
break;
default:
EditorGUILayout.LabelField("Value is Unknown");
break;
}
if(EditorGUI.EndChangeCheck())
{
serializedObject.ApplyModifiedProperties();
}
}
}
Thank you, I will try this when I will get home ![]()
Are you telling me I should not call the function in my target script from my editor script? Because I kinda need to, the way you have it set up, is similar to the way I had it before, but it causes another problem. Let me make another video on this.
@WarmedxMints_1
So I made some changes, And now I am back to my original problem.
I talked about my original problem a little bit in this post: