Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question UIElement Property-Drawer in IMGUI Inspector "No GUI Implemented"

Discussion in 'UI Toolkit' started by SchmidtDavidSimon, Dec 2, 2021.

  1. SchmidtDavidSimon

    SchmidtDavidSimon

    Joined:
    Sep 7, 2020
    Posts:
    13
    Hi all,
    So I tried to create a property drawer using
    CreatePropertyGUI
    and use it in my project. If I try to use it in an inspector driven by IMGUI I get the "No GUI Implemented" error. I've read already read that It's probably because of the IMGUI/UiElement Mix. Is there any solution yet? I'll provide my scripts and a simple example project. Please mind that for the real one I'm bound to Unity 2020.16.3.

    Code (CSharp):
    1. public class BaseClass : MonoBehaviour
    2. {
    3.     [SerializeField] private List<Property> Properties;
    4. }
    Code (CSharp):
    1. [Serializable]
    2. public class Property
    3. {
    4.     [SerializeField] private bool isOn;
    5.     [SerializeField] private string name;
    6.     [SerializeField] private float length;
    7. }
    Code (CSharp):
    1. [CustomEditor(typeof(BaseClass))]
    2. public class BaseInspector : Editor
    3. {
    4.     public override void OnInspectorGUI()
    5.     {
    6.         DrawDefaultInspector();
    7.     }
    8. }
    Code (CSharp):
    1. [CustomPropertyDrawer(typeof(Property))]
    2. public class PropertyDrawer : UnityEditor.PropertyDrawer
    3. {
    4.     public override VisualElement CreatePropertyGUI(SerializedProperty property)
    5.     {
    6.         var container = new VisualElement();
    7.  
    8.         var isOnField = new PropertyField(property.FindPropertyRelative("isOn"));
    9.         var nameField = new PropertyField(property.FindPropertyRelative("name"));
    10.         var lengthField = new PropertyField(property.FindPropertyRelative("length"));
    11.      
    12.         container.Add(isOnField);
    13.         container.Add(nameField);
    14.         container.Add(lengthField);
    15.  
    16.         return container;
    17.     }
    18. }
     

    Attached Files:

  2. billykater

    billykater

    Joined:
    Mar 12, 2011
    Posts:
    327
    the thread with all the answers: Property Drawers. Specifically this code sample should make it easy to implement.

    TL;DR: Your editor/editorwindow currently needs to be UIElements for UIElements Property Drawers to work.
     
  3. SchmidtDavidSimon

    SchmidtDavidSimon

    Joined:
    Sep 7, 2020
    Posts:
    13
    Thanks for the reply, that thread was really helpful!