Unity C# 枚举多选

枚举多选

  • 例子
  • 判断

Unity C# 枚举多选_第1张图片

例子

   [System.Flags]
   public enum TestEnum{ 
       None =  0,
       Rooms = 1 << 1,
       Walls=1<<2,
       Objects=1<<3,
       Slabs = 1 << 4,
       All = Rooms|Walls|Objects|Slabs
   }

判断

TestEnum test = TestEnum.Rooms;
bool isRooms = (test.input & TestEnum.Rooms ) != TestEnum.None;

你可能感兴趣的:(C#,Unity,unity,c#,枚举多选)