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 nuhash · Dec 30, 2012 at 01:10 PM · inspectorenum

Add to enum list from inspector

I want to use an enum to contain values for "flags" which the player can set off by completing parts of the story, quests or interacting with objects in the game. As this list of flags will increase during development I would like to be able to add a flag to the enum from within unity rather than doing by hand.

Please I dont want to change it at runtime I want to edit the actual declaration from within Unity before compilation. It seems that layers work by enums and they can be edited from within unity.

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
Best Answer

Answer by Drakmyth · Dec 30, 2012 at 08:30 PM

I don't know for sure, but I'm guessing that layers are implemented as a list. If you expose a list (or array, or any other collection type) to the inspector, you can modify its contents directly.

I'm a little new to unity and haven't dealt with transferring data across scenes, but I would place an empty GameObject in the scene to serve as a SceneController and would place a script on this object. This script would contain a Dictionary , then you can access this via scripts with the GetComponent method.

As far as I'm aware, Unity does not currently have a Dictionary inspector, but a quick search suggests that it isn't too difficult to make one. Alternatively, you could expose two lists to the inspector (one for keys, the other for values) then combine them into a dictionary in the script's Start or Awake method.

This isn't really a case for an enum as those merely define a series of constants. Being constants, they cannot be defined at runtime and can't really be used to store data, unless used in combination with a list or dictionary.

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 nuhash · Dec 30, 2012 at 10:15 PM 0
Share

I am fairly new to Unity as well, haven't done much with it, the main problem I am having is that I assume C# has the same/similar functionality as C++. Thanks for suggesting the Dictionary, its actually perfect for what I need and its faster than Lists!!! Yay for less slowdowns!!!

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

9 People are following this question.

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

Related Questions

c# enum wont show in inspector 3 Answers

Insert enum breaking existing inspector values 2 Answers

Restrict which types of an Enum can be selected in inspector. 5 Answers

How can i show enum description in Inspector? 2 Answers

Flagged Enum representation in Inspector 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