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 Custom Editor Not Displaying

Discussion in 'Scripting' started by grqphical, Dec 22, 2021.

  1. grqphical

    grqphical

    Joined:
    Jul 15, 2021
    Posts:
    10
    Hello. I am trying to get a custom editor to display so I can change the properties of a scriptable object I have but for some reason it seems the OnInspectorGui() function isn't being called. Planet is a script I have, shapesettings and coloursettings are two scriptable objects I have to control properties of a generated mesh

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEditor;
    5.  
    6. [CustomEditor(typeof(Planet))]
    7. public class PlanetEdtior : Editor
    8. {
    9.  
    10.     Planet planet;
    11.  
    12.     private void OnEnable()
    13.     {
    14.         planet = (Planet)target;
    15.     }
    16.     public override void OnInspectorGUI()
    17.     {
    18.         base.OnInspectorGUI();
    19.  
    20.         DrawSettingsEditor(planet.shapeSettings);
    21.         DrawSettingsEditor(planet.colourSettings);
    22.     }
    23.  
    24.     void DrawSettingsEditor(Object settings)
    25.     {
    26.         Editor editor = CreateEditor(settings);
    27.         editor.OnInspectorGUI();
    28.     }
     
    lemapp, Tony_Max and CTN-Originals like this.
  2. CTN-Originals

    CTN-Originals

    Joined:
    May 30, 2020
    Posts:
    6
    I don't know too much about custom inspectors but I remember making a custom window to easily display information like this without having to code some new editor script every time I got a new inspector I wanted to display.
    It might help you too with that so here is the video that explains how to do that:
     
  3. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    334
    Have you found any solutions?