コード例 #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EnumFlagAttribute flagSettings = (EnumFlagAttribute)attribute;

            System.Enum targetEnum = (System.Enum)System.Enum.ToObject(fieldInfo.FieldType, property.intValue);
            EditorGUI.BeginProperty(position, label, property);
            position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
            System.Enum enumNew = EditorGUI.EnumMaskField(position, targetEnum);
            property.intValue = (int)System.Convert.ChangeType(enumNew, targetEnum.GetType());
            EditorGUI.EndProperty();
        }
コード例 #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (property.serializedObject.isEditingMultipleObjects)
            {
                EditorGUI.LabelField(position, "Multi-edit not supported");
                return;
            }

            EnumFlagAttribute flagSettings = (EnumFlagAttribute)attribute;

            System.Enum targetEnum = (System.Enum)System.Enum.ToObject(fieldInfo.FieldType, property.intValue);
            string      tooltip    = (attribute as WeatherMaker.EnumFlagAttribute).Tooltip;

            if (!string.IsNullOrEmpty(tooltip))
            {
                label.tooltip = tooltip;
            }
            EditorGUI.BeginProperty(position, label, property);
            position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
            System.Enum enumNew = EditorGUI.EnumFlagsField(position, targetEnum);
            property.intValue = (int)System.Convert.ChangeType(enumNew, targetEnum.GetType());
            EditorGUI.EndProperty();
        }