void OnGroupSelected(FlagsOption option, SerializedProperty property)
        {
            var groups = property.GetValue<ByteFlag>();

            switch (option.Type)
            {
                case FlagsOption.OptionTypes.Everything:
                    foreach (var data in groupData)
                        groups |= data.Group;
                    break;
                case FlagsOption.OptionTypes.Nothing:
                    groups = ByteFlag.Nothing;
                    break;
                case FlagsOption.OptionTypes.Custom:
                    var group = ((GroupData)option.Value).Group;

                    if (option.IsSelected)
                        groups &= ~group;
                    else
                        groups |= group;
                    break;
            }

            for (int i = 1; i <= 8; i++)
            {
                var flagName = "f" + i;
                property.FindPropertyRelative(flagName).intValue = groups.GetValueFromMember<int>(flagName);
            }

            property.serializedObject.ApplyModifiedProperties();
            EditorUtility.SetDirty(property.serializedObject.targetObject);
        }
Beispiel #2
0
        void OnEnumFlagSelected(FlagsOption option, SerializedProperty property)
        {
            var flags = property.GetValue <IEnumFlag>();

            switch (option.Type)
            {
            case FlagsOption.OptionTypes.Everything:
                foreach (IEnumFlag value in enumValues)
                {
                    flags = flags.Add(value);
                }
                break;

            case FlagsOption.OptionTypes.Nothing:
                foreach (IEnumFlag value in enumValues)
                {
                    flags = flags.Remove(value);
                }
                break;

            case FlagsOption.OptionTypes.Custom:
                if (option.IsSelected)
                {
                    flags = flags.Remove((IEnumFlag)option.Value);
                }
                else
                {
                    flags = flags.Add((IEnumFlag)option.Value);
                }
                break;
            }

            property.SetValue(flags);
        }
Beispiel #3
0
        void ShowEnumFlag()
        {
            var enumFlagValue = currentProperty.GetValue <IEnumFlag>();
            var options       = new FlagsOption[enumValues.Length];

            for (int i = 0; i < options.Length; i++)
            {
                var flags = (IEnumFlag)enumValues.GetValue(i);
                options[i] = new FlagsOption(enumNames[i].ToGUIContent(), flags, enumFlagValue.HasAll(flags));
            }

            Flags(currentPosition, currentProperty, options, OnEnumFlagSelected, currentLabel);
        }
Beispiel #4
0
        void ShowGroups()
        {
            var flags   = currentProperty.GetValue <ByteFlag>();
            var options = new FlagsOption[groupData.Count];

            for (int i = 0; i < options.Length; i++)
            {
                var group = groupData[i];
                var name  = group.GroupName.Replace('_', '/').ToGUIContent();
                options[i] = new FlagsOption(name, group, EntityMatchOld.Matches(flags, group.Group));
            }

            Flags(currentPosition, currentProperty, options, OnGroupSelected, currentLabel);
        }
Beispiel #5
0
        void OnGroupSelected(FlagsOption option, SerializedProperty property)
        {
            var groups = property.GetValue <ByteFlag>();

            switch (option.Type)
            {
            case FlagsOption.OptionTypes.Everything:
                foreach (var data in groupData)
                {
                    groups |= data.Group;
                }
                break;

            case FlagsOption.OptionTypes.Nothing:
                groups = ByteFlag.Nothing;
                break;

            case FlagsOption.OptionTypes.Custom:
                var group = ((GroupData)option.Value).Group;

                if (option.IsSelected)
                {
                    groups &= ~group;
                }
                else
                {
                    groups |= group;
                }
                break;
            }

            for (int i = 1; i <= 8; i++)
            {
                var flagName = "f" + i;
                property.FindPropertyRelative(flagName).intValue = groups.GetValueFromMember <int>(flagName);
            }

            property.serializedObject.ApplyModifiedProperties();
            EditorUtility.SetDirty(property.serializedObject.targetObject);
        }
        void ShowGroups()
        {
            var flags = currentProperty.GetValue<ByteFlag>();
            var options = new FlagsOption[groupData.Count];

            for (int i = 0; i < options.Length; i++)
            {
                var group = groupData[i];
                var name = group.GroupName.Replace('_', '/').ToGUIContent();
                options[i] = new FlagsOption(name, group, EntityMatchOld.Matches(flags, group.Group));
            }

            Flags(currentPosition, currentProperty, options, OnGroupSelected, currentLabel);
        }