Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. 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:
    204
    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:
    285
    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.