- Home /
 
CustomEditor Not Working or Visible
I'm having an issue with CustomEditor's not actually showing.
I have a controller (MonoBehaviour) that has an array of Interaction attached to it. The Interaction class looks like:
 [Serializable]
 public class Interaction
 {
     public ConditionContainer[] Conditions;
 }
 
               ConditionContainer is a way to wrap up and instantiate actual Conditions for an Interaction to occur (i.e. bumped into, press a key, etc).
 [Serializable]
 public class ConditionContainer : ScriptableObject
 { 
     public ConditionType ConditionType;
     public Condition Condition;
     public bool IsMet()
     {
         if( Condition != null )
         {
             return Condition.IsMet();
         }
         return true;
     }
 }
 
               Condition itself is an abstract class and I was planning on instantiating it in my CustomEditor, based on the ConditionType that was set, and having CustomEditor's for each specific Condition (i.e. BumpedIntoCondition, PressedKeyCondition).
 [Serializable]
 public abstract class Condition
 {
     public ConditionType ConditionType;
     public virtual bool IsMet()
     {
         return true;
     }
 }
 
               My CustomEditor's NEVER display or work. I don't know if it's because they don't play well with arrays or if I'm missing some kind of derivation or attribute or what.
Just trying to output a label that says "Hello World" fails...
 [CustomEditor(typeof(ConditionContainer), true)]
 [CanEditMultipleObjects]
 public class ConditionContainerEditor : Editor
 { 
     public override void OnInspectorGUI()
     {
         //serializedObject.Update(); 
         EditorGUILayout.LabelField("Hello World"); 
         //serializedObject.ApplyModifiedProperties();
     }
 }
 
               Am I missing something? I've commented out the serializedObject details, but they don't make a difference either way. I've tried calling into the base.OnInspectorGUI() as well... No luck anywhere. The Editor itself is inside Assets\Editor -- when I open the code, it tosses it into another C# Project called "Editors" so I assume it's recognizing.
I'm using Unity 2017.3 Personal.
Haven't spotted anything wrong. Can you clarify if it's showing nothing in the inspector, or showing the default editor?
Answer by terinfire · Feb 26, 2018 at 07:54 PM
Also, please note that on my InteractionContoller, I have a
 public ConditionContainer Condition;
 
               which also does not show the Custom Editor.
Answer by altschuler · Feb 22, 2019 at 01:06 PM
If you're using namespaces try removing it from the editor class, ie. just don't namespace the editor, namespacing the behaviour is fine.
Any particular reason? I would never create any class in the global namespace, including custom editors. They work fine in namespaces.
Your answer