I am starting to learn about custom editors to create a better inspector for my AI settings.
With so many settings, I decided to create a bool that while unchecked will hide things that I don’t need to change.
But, I could not find a way to create a read-only object field that opens the script when clicked, while every monobehaviours class has it in it’s default inspector.
By now, I am using a simple label to just act like an “placeholder” (as show in “AIBehaviourShoot”) for the desired label (as show in “AIBehaviourChase” and every other default inspector).
and here is my current script:
using UnityEditor;
[CustomEditor(typeof(AIBehaviourChase))]
[CanEditMultipleObjects]
public class AIBehaviourChaseEditor : Editor
{
SerializedProperty canChase;
private void OnEnable()
{
canChase = serializedObject.FindProperty("canChase");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
if (!canChase.hasMultipleDifferentValues)
{
if (canChase.boolValue)
{
// the defaul inspector shows the read-only object field
DrawDefaultInspector();
}
else
{
// this is the placeholder label that I want to change.
EditorGUILayout.LabelField("Script", "AIBehaviourChase");
canChase.boolValue = EditorGUILayout.Toggle("Can Chase", canChase.boolValue);
}
}
serializedObject.ApplyModifiedProperties();
}
}
Sorry my english.
EDIT: There is no way of doing it?