EnumFlags.cs 903 B

1234567891011121314151617181920212223242526272829303132
  1. //======= Copyright (c) Valve Corporation, All rights reserved. ===============
  2. //
  3. // Purpose: Allows Enums to be shown in the inspector as flags
  4. //
  5. //=============================================================================
  6. using UnityEngine;
  7. #if UNITY_EDITOR
  8. using UnityEditor;
  9. #endif
  10. namespace Valve.VR.InteractionSystem
  11. {
  12. //-------------------------------------------------------------------------
  13. public class EnumFlags : PropertyAttribute
  14. {
  15. public EnumFlags() { }
  16. }
  17. #if UNITY_EDITOR
  18. //-------------------------------------------------------------------------
  19. [CustomPropertyDrawer( typeof( EnumFlags ) )]
  20. public class EnumFlagsPropertyDrawer : PropertyDrawer
  21. {
  22. public override void OnGUI( Rect position, SerializedProperty property, GUIContent label )
  23. {
  24. property.intValue = EditorGUI.MaskField( position, label, property.intValue, property.enumNames );
  25. }
  26. }
  27. #endif
  28. }