Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 hexagonius · Mar 02, 2017 at 11:48 AM · enumdropdownintegergenericsabstract

enum in generic subclass shows as integer

I just recently discovered that using enum fields in an abstract generic class (like the good old Singleton<T>), only show up as integer fields and not as drop down menus in derived classes.

Why is that? Is it a bug?

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
0

Answer by Bunny83 · Mar 02, 2017 at 01:15 PM

You gave not much information about your exact case. So i went ahead and created two test cases. Since only serializable classes will show up in the inspector it should be clear that the classes either are "System.Serializable" or derived from MonoBehaviour / ScriptableObject.

First i created an abstract generic base class that was derived from MonoBehaviour. The base class has a public field of an enum type. I then created an non-abstract non-generic subclass of that base class and attached it to a gameobject. The enum shows up as dropdown as expected.

For the second test i created a serializable abstract generic class that is derived from System.Object (a normal class) with the same public enum field. Then again i created a non-generic non-abstract subclass which i exposed in a seperate MonoBehaviour class as public variable. If i inspec that MonoBehaviour i see the serializable class as expandable field. The enum of that class also shows up as drop down.

Tests has been carried out in Unity 5.5.1f1

You either have a strange setup that Unity even can't serialize properly because the actual class used is either generic or abstract, you have a custom inspector / propertydrawer which messes up the display of the enum or you have set your inspector to debug mode. Which of those three reasons apply to you we can't determine by the information given in the question.

Comment
Add comment · Show 4 · 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 hexagonius · Mar 02, 2017 at 07:45 PM 0
Share

I was referring to your test case 1. I'll check which version it is on monday.
none of your exceptions apply in my case.
funny enough another enum in the derived class, created and made a field of, showed up properly.
I usually know how to create properly serialized classes and fields, which is why I'm so confused.
let's see in monday. thanks however for your thorough perimiter (if that's even English, I'm German :) )

avatar image Bunny83 hexagonius · Mar 02, 2017 at 08:09 PM 0
Share

Hmm, i've even tried enums with different underlying types (byte, uint, long) and all work the same way. I also tried enum members which do not have consecutive values (like when used as bit flags). No matter what i do the enum always shows up as expected ^^.

:) No worries, I'm german as well ^^

avatar image hexagonius Bunny83 · Mar 08, 2017 at 11:07 AM 0
Share

@Bunny83 Ok, sorry it wasn't monday. I thought I'd show a screenshot even if there's code, but you can also see the rest of the settings. Actually I don't understand the behaviour really. You can see the enum showing up with 0 at the bottom of the inspector:

Screenshot of one abstract an one derived class and also showing the inspector with the fields

Show more comments

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

65 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

Related Questions

Drop-down enum pauses player - must it be so? 1 Answer

Drop down menu not working how I expected 1 Answer

Variable Scroll How do I make it Scroll 1 Answer

Create Enumeration from List 0 Answers

C# How to use inherited generic abstract class with specific type. 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