Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by terinfire · Feb 26, 2018 at 07:53 PM · custom editorcustom-inspector

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.

https://imgur.com/a/LnUgI

I'm using Unity 2017.3 Personal.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bonfire-Boy · Feb 22, 2019 at 04:44 PM 0
Share

Haven't spotted anything wrong. Can you clarify if it's showing nothing in the inspector, or showing the default editor?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bonfire-Boy · Feb 22, 2019 at 04:36 PM 0
Share

Any particular reason? I would never create any class in the global namespace, including custom editors. They work fine in namespaces.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

77 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to Call the default Editor of a ScriptableObject From the other ScriptableObject's OnInspectorGUI()? 1 Answer

Dictionary becomes null unexpectedly when using a custom inspector 2 Answers

Null reference exceptions when using a Custom Editor 0 Answers

Custom Window with Hierarchy 1 Answer

Create a custom prefab stage 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges