示例#1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            InitDrawerFieldsIfNeeded();
            CheckFlagsTypeCompatibility();
            BitFlags32 flags = (BitFlags32)((byte)property.intValue);

            Vector2 toggleRectSize = new Vector2(position.size.x, cache.ToggleHeight);

            EditorGUI.BeginProperty(position, label, property);

            for (int i = 0, propIndex = 0, length = cache.FlagFields.Names.Count; i < length; i++)
            {
                if (cache.FlagFields.Names[i] != null)
                {
                    BitFlags32 flag = (BitFlags32)(1 << i);

                    bool isChecked = EditorGUI.Toggle(
                        new Rect(
                            new Vector2(position.x, position.y + ToggleControlHeight * propIndex),
                            toggleRectSize),
                        cache.FlagsContent[i],
                        flags.HasAllFlags(flag));
                    flags = flags.WithFlagsSetTo(flag, isChecked);
                    propIndex++;
                }
            }
            setPropertyValue(property, flags);

            EditorGUI.EndProperty();
        }
示例#2
0
 private void SetPropertySByteValue(
     SerializedProperty property, BitFlags32 flags)
 {
     property.intValue = (sbyte)flags;
 }