public class ttttttTestBase<T> : MonoBehaviour
{
[SerializeField] private T value;
}
public class ttttttTest : ttttttTestBase<string>
{
}
[CustomEditor(typeof(ttttttTestBase<>), true)]
public class ttttttTestBaseEditor : Editor
{
public override void OnInspectorGUI()
{
}
}
This is my test code. It works in the editor2019. But it doesn’t work in the editor2022.3.11f1c1
In the editor2019:
in the editor2022.3.11f1c1:
My project uses the editor 2022.3.11f1c1
„doesn‘t work“ is not a problem description
unless you mixed up the screenshots, the 2019 version is the one that looks broken
No I think it’s correct. I think their point is to show that in 2019 their custom editor overrides the inspector (in this case, drawing nothing), while that doesn’t happen in 2022.
Mind you Unity’s generic support has always been terrible. I wish we’d get proper generic type matching the way Odin does it: https://odininspector.com/tutorials/how-to-create-custom-drawers-using-odin/understanding-generic-constraints-on-odin-drawers
Too many situations where I just can’t use an editor or property drawer because generics are involved.
I want to draw custom gui in OnInspectorGUI().
Like this:
[CustomEditor(typeof(ttttttTestBase<>), true)]
public class ttttttTestBaseEditor : Editor
{
private SerializedProperty valueProp = null;
private void OnEnable() {
valueProp = serializedObject.FindProperty("value");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.PropertyField(valueProp);
EditorGUILayout.Space(10);
if (GUILayout.Button("Button")) {
Debug.Log(valueProp.stringValue);
}
serializedObject.ApplyModifiedProperties();
}
}
In the editor2019:
in the editor2022.3.11f1c1: