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
0
Question by Kristov · Jun 22, 2011 at 04:31 AM · editorenumcustom-editor

Custom editor not editing?

Hi all,

I've been trying to get a script of mine to only display some variables in the inspector if an enum is at a particular value. I see I have to use a Custom Editor to do this. I've been fiddling with one for a while now, but it doesn't seem to work at all - I don't think it's registering what script it's supposed to be editing?

Here's the PanelCustomInspector.js in the Editor folder:

 @CustomEditor(PanelController)
 
 var types : panelTypes;
 var directions : pathDirections;
 
 class PanelCustomInspector extends Editor
 {
     function OnInspectorGUI()
     {
         EditorGUILayout.LabelField("This is" , "a test.");
         target.panelType = EditorGUILayout.EnumPopup(types);
         var workaround : panelTypes = target.panelType; //[necessary][1]
         if(workaround == panelTypes.Path)
         {
             target.pathDirection = EditorGUILayout.EnumPopup(directions);
         }
     }
 }

And here's the PanelController.js in a different folder:

 var panelType = panelTypes.Buildable;
 var pathDirection = pathDirections.Right;
 
 function OnDrawGizmos()
 {
     //Draw a particular gizmo, depending on what direction the path is
 }

The editor just shows the panelType and pathDirection variables of the PanelController.js script and the test label doesn't show up. Any help would be appreciated!

[1]: http://answers.unity3d.com/questions/25453/comparing-enum-from-a-class-in-an-editor-script-do.html

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Waz · Jun 22, 2011 at 05:40 AM

Move the variables "types" and "directions" to Inside the class.

A JS files with anything but a single class declaration is magically wrapped into a class named by the file, so your code would be a class nested inside a class of the same name, or something weird like that.

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 Kristov · Jun 22, 2011 at 05:46 AM 0
Share

Though I don't understand what on earth it was about, it worked, so I'm happy, thanks! Only thing is, the variables won't edit. Probably something silly I've done in the coding. Can't for the life of me see what though

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to create bitmask flags per scene that are available in the editor? 0 Answers

Accessing enum from editor script returns null 1 Answer

DropDownList with string array in Editor Inspector 5 Answers

EnumPopup an enum from another class 1 Answer

Create Spells through classes in custom editor? 1 Answer


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