Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 d112570 · May 25, 2015 at 04:03 PM · editorguienumpopup

EditorGUILayout.EnumPopup not found

I have this simple editor script and I can't seem to find the problem.

 using UnityEngine;
 using System.Collections;
 
 public class Info : MonoBehaviour {
 
     public enum Category {Armor, Consumable, Necklace, Ring, Scroll, Shield, Weapon}
     public enum ArmorType {Breast, Feet, Hands, Head, Shoulder}
 
     public string Name;
     public Category category;
     public ArmorType armorType;
     public int Armor;
     public int Health;
     public int Mana;
     public int Attack;
     public int Intelligence;
 }

Editor script is here; The 2 with the enumpopup do not work, it says missing category and armortype.

 using UnityEngine;
 using UnityEditor;
 using System.Collections.Generic;
 using System.Collections;
 using System;
 
 [CustomEditor(typeof(Info))]
 public class InfoEditor : Editor
 
 {
     bool myBool = false;
 
     public override void OnInspectorGUI()
     {
         myBool = EditorGUILayout.Toggle ("Show Original", myBool);
         if (myBool == true) base.OnInspectorGUI();
         Info myTarget = (Info)target;
 
         myTarget.Name = EditorGUILayout.TextField("Name", myTarget.Name);
         myTarget.category   = (Category )EditorGUILayout.EnumPopup("Category",  myTarget.category); // Error message here
         myTarget.armorType     = (ArmorType)EditorGUILayout.EnumPopup("Armor Type",myTarget.armorType); // Error message here
 
         if (myTarget.category.ToString() == "Consumable"){
             myTarget.Health = EditorGUILayout.IntField("Health", myTarget.Health);
             myTarget.Mana = EditorGUILayout.IntField("Mana", myTarget.Mana);
         }
         if (myTarget.category.ToString() == "Armor"){
             myTarget.Armor = EditorGUILayout.IntField("Armor", myTarget.Armor);
             
         }
     }
 }

When I comment out those 2 errors everything else works. Could anyone find where the problem is?

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 Lo0NuhtiK · May 25, 2015 at 04:59 PM

You either need to move your two enums outside of the Info class... eg:

 public enum Category{}
 public enum ArmorType{}
 
 public class Info{.....}

Or you need to do :

 myTarget.category  = (Info.Category )...
 myTarget.armorType = (Info.ArmorType)...

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 d112570 · May 25, 2015 at 06:13 PM 0
Share

Oh my goodness, didn't even notice I did that, I'm glad someone else looked at the code and caught it.

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

20 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

Related Questions

How to provide custom descriptions for EditorGUI.EnumPopup? 1 Answer

The popup when clicking an EditorGUI.EnumPopup inside a scaled GUI.matrix, is opened in the wrong location 1 Answer

Initialising List array for use in a custom Editor 1 Answer

How do I add a drop-down menu to an EditorWindow? 3 Answers

Editor Scripts in Dll 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