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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Handle custom classes on custom inspectors

Discussion in 'Scripting' started by Luxgile, Mar 22, 2019.

  1. Luxgile

    Luxgile

    Joined:
    Nov 27, 2016
    Posts:
    16
    Okay so let's say i have a class A which is just a class i made and it doesn't inherit from nothing and i have a class B which is a MonoBehaviour. If i want class A to show up in the inspector i must attach it to some UnityEngine.Object like the MonoBehaviour and make it serializable, so far so good.

    The problem comes when i'm making a custom inspector for class B. I make the inspector and everything cool and nice using EditorGUILayout and stuff until i want to draw class B. What i want to know is, is there any way to make some kind of EditorGUILayout.DrawClass(classB) or Editor.CreateCachedEditor(classB) which just draws class B the default way or i have to manually draw every element of class B on the custom editor?
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,748
  3. Luxgile

    Luxgile

    Joined:
    Nov 27, 2016
    Posts:
    16
    That would only work with the default inspector, i need to call a method in OnInspectorGUI that draws that class for me