Exemplo n.º 1
0
        public static void DrawTagField(Rect position, SerializedProperty property, FieldOption options)
        {
            if (property.propertyType != SerializedPropertyType.String)
            {
                position = MightyGUIUtilities.DrawPropertyField(position, property);
                MightyGUIUtilities.DrawHelpBox(position, $"\"{property.displayName}\" should be of type string");
                return;
            }

            string tag;

            if (options.Contains(FieldOption.HideLabel))
            {
                tag = EditorGUI.TagField(position, property.stringValue);
            }
            else if (options.Contains(FieldOption.BoldLabel))
            {
                tag = EditorGUI.TagField(position, property.displayName, property.stringValue, EditorStyles.boldLabel);
            }
            else
            {
                tag = EditorGUI.TagField(position, property.displayName, property.stringValue);
            }

            property.stringValue = tag;
        }
Exemplo n.º 2
0
        public static void DrawTagField(SerializedProperty property, FieldOption options, GUIContent label = null)
        {
            if (property.propertyType != SerializedPropertyType.String)
            {
                MightyGUIUtilities.DrawPropertyField(property, label);
                MightyGUIUtilities.DrawHelpBox($"\"{property.displayName}\" should be of type string");
                return;
            }

            string tag;

            if (options.Contains(FieldOption.HideLabel))
            {
                tag = EditorGUILayout.TagField(property.stringValue);
            }
            else if (options.Contains(FieldOption.BoldLabel))
            {
                tag = EditorGUILayout.TagField(label ?? EditorGUIUtility.TrTextContent(property.displayName), property.stringValue,
                                               EditorStyles.boldLabel);
            }
            else
            {
                tag = EditorGUILayout.TagField(label ?? EditorGUIUtility.TrTextContent(property.displayName), property.stringValue);
            }

            property.stringValue = tag;
        }
Exemplo n.º 3
0
        protected bool DrawLabel(ref Rect position, SerializedProperty property, FieldOption options,
                                 GUIContent label)
        {
            if (options.Contains(FieldOption.HideLabel))
            {
                return(false);
            }

            var labelPosition = new Rect(position.x, position.y, position.width, MightyGUIUtilities.FIELD_HEIGHT);

            position = !options.Contains(FieldOption.BoldLabel)
                ? DrawNormalLabel(labelPosition, property, label)
                : DrawBoldLabel(labelPosition, property, label);
            return(true);
        }
Exemplo n.º 4
0
        private float GetFieldHeight(FieldOption options)
        {
            switch (Orientation)
            {
            case Orientation.Horizontal:
                return(options.Contains(FieldOption.HideLabel) || EditorGUIUtility.wideMode
                        ? MightyGUIUtilities.FIELD_HEIGHT
                        : MightyGUIUtilities.FIELD_HEIGHT * 2);

            case Orientation.Vertical:
                return(options.Contains(FieldOption.HideLabel) || EditorGUIUtility.wideMode
                        ? MightyGUIUtilities.VERTICAL_FIELD_HEIGHT
                        : MightyGUIUtilities.FIELD_HEIGHT + MightyGUIUtilities.VERTICAL_FIELD_HEIGHT);
            }

            return(0);
        }
Exemplo n.º 5
0
        protected bool DrawLabel(SerializedProperty property, FieldOption options, GUIContent label = null)
        {
            if (options.Contains(FieldOption.HideLabel))
            {
                return(false);
            }

            if (!options.Contains(FieldOption.BoldLabel))
            {
                DrawNormalLabel(property, label);
            }
            else
            {
                DrawBoldLabel(property, label);
            }

            return(true);
        }
Exemplo n.º 6
0
        public void DrawSlider(SerializedProperty property, FieldOption option, GUIContent label = null)
        {
            if (property.propertyType != SerializedPropertyType.Integer)
            {
                MightyGUIUtilities.DrawPropertyField(property, label);
                MightyGUIUtilities.DrawHelpBox($"{nameof(SceneSliderAttribute)} can be used only on int fields");
                return;
            }

            var max = SceneManager.sceneCountInBuildSettings - 1;

            property.intValue = option.Contains(FieldOption.HideLabel)
                ? EditorGUILayout.IntSlider(property.intValue, 0, max)
                : EditorGUILayout.IntSlider(label ?? EditorGUIUtility.TrTextContent(property.displayName), property.intValue, 0, max);

            EditorGUILayout.LabelField(Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(property.intValue)),
                                       EditorStyles.boldLabel);
        }
Exemplo n.º 7
0
        public void DrawSlider(Rect position, SerializedProperty property, FieldOption option)
        {
            if (property.propertyType != SerializedPropertyType.Integer)
            {
                position = MightyGUIUtilities.DrawPropertyField(position, property);
                MightyGUIUtilities.DrawHelpBox(position, $"{nameof(SceneSliderAttribute)} can be used only on int fields");
                return;
            }

            var max = SceneManager.sceneCountInBuildSettings - 1;

            position.height = MightyGUIUtilities.FIELD_HEIGHT;

            property.intValue = option.Contains(FieldOption.HideLabel)
                ? EditorGUI.IntSlider(position, property.intValue, 0, max)
                : EditorGUI.IntSlider(position, property.displayName, property.intValue, 0, max);

            position = MightyGUIUtilities.JumpLine(position, false);

            EditorGUI.LabelField(position, Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(property.intValue)),
                                 EditorStyles.boldLabel);
        }