Search Unity

  1. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  2. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  3. If you couldn't join the live stream, take a peek at what you missed.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Mask field with support for more than 32 elements

Discussion in 'Extensions & OnGUI' started by RealMTG, Jun 10, 2018.

  1. RealMTG

    RealMTG

    Joined:
    Jul 27, 2013
    Posts:
    194
    Hello

    I have a big array of items that I want to be able to select from and I would like to select multiple of them. I tried using EditorGUI.MaskField but apparently it only supports 32 elements and then it starts to wrap around on itself (if I select the first item, it will also select the 33rd item). I can also not use an enum and EnumFlagField due to this array of strings not being static.
    Is there anything I can use for my situation?

    Thanks
     
  2. brownboot67

    brownboot67

    Joined:
    Jan 5, 2013
    Posts:
    261
    The mask field works via bit masking. This means each element in the array must have an int value that is a power of 2. I don't believe you can support a mask greater than 32 elements as a result because the int values will no longer be unique. So you're going to have to split your list into multiple masks or rethink your design.