Search Unity

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:
    218
    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:
    322
    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.