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 sharkweek42 · Feb 17, 2017 at 10:29 PM · editoreditor-scriptingenumpropertydrawercustom-editor

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

Hello! My current project is a 3D anatomy exploration app that will show labeled parts of the human anatomy. Clicking on a label turns off rendering of all parts outside the selected region, zooms in and rotates the model to give a better view of the selected region, and exposes subregions of the selected region for further exploration. For example, at the top level you'd have head, arm, torso, leg, etc. If you select the arm label, you'd get shoulder, upper arm, forearm, hand.

To facilitate this functionality I first implemented a solution using enum flags as explained in these threads:

http://answers.unity3d.com/questions/486694/default-editor-enum-as-flags-.html

http://answers.unity3d.com/questions/393992/custom-inspector-multi-select-enum-dropdown.html

I'd like to use flags because a particular part can be visible for more than one region. However, after setting up part of the arm I realized this solution would limit me to 32 total regions and I'll likely need far more than that for the entire body. Additionally, we're planning on having small "story" scenes that step through small sections of the anatomy and explain their relation to each other. These scenes will likely need to define their own regions rather than use the ones I've set up for the full body. I realize I could instead switch to a long enum, but that seems like a band-aid fix and it doesn't solve the problem with the story scenes having to deal with all of the regions of the body.

What I'd like to do is switch the enum flags to an array of bools where each entry in the array corresponds to an anatomy region. The problem with this is I'm not sure how to force each bool array on each object in the scene to have the same length. Furthermore, I'm not sure how to set up a custom editor script so the labels on each entry in the array correspond to predefined region names in that scene. I tried using an array of strings on a singleton object in the scene, but that doesn't work because the singleton object isn't active available in the editor.

After doing a bit of digging it looks like ScriptableObjects might help me out here, but I'm not sure how to make them available to a custom Editor or PropertyDrawer script. I'm also not sure how to force the same length on every bit array in the scene.

After typing all of this out it has occurred to me that I could simply continue to use enums, but switch to a list and simply check if an object's region enum list contains the active region. However I'd still like to know if there's a way to dynamically rename things in the editor through a ScriptableObject rather than hardcoding the name into my editor script!

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

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Custom editor not editing? 1 Answer

Custom editor tags not saving 1 Answer

Draw inspector of array elements? 1 Answer

Trouble setting the object reference in a property drawer 0 Answers

SerializedProperty with children class fields 2 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