Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Custom bitfield menus in the inspector

Discussion in 'Scripting' started by NCarter, Dec 10, 2006.

  1. NCarter

    NCarter

    Joined:
    Sep 3, 2005
    Posts:
    686
    I notice that the LayerMask type, when used as a public member variable, shows as a special kind of popup menu in the inspector. Is it there any way I can make custom menus for my own bitfield types?

    I'm looking at this because I'm considering the best way of describing to the AI which kind(s) of target it is and which kind(s) or target it likes to shoot at. A bitfield seems preferable to a set of booleans for this purpose, since it's easier to apply a bitmask than to test a set of booleans against one another. However, it's not such a good idea if I have to punch bits into the inspector in decimal!
     
  2. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    I'm afraid not. The LayerMask popus were completely custom made for this particular bitfield (and the source of an unrealistic number of bugs. IIRC, they didn't work proper from scripting until 1.5 or 1.6)...
     
  3. NCarter

    NCarter

    Joined:
    Sep 3, 2005
    Posts:
    686
    Thanks for the insight. :)

    I'll work something else out instead, like a serialisable custom class.