internal override void OnGUI(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
        {
            EmbeddedAttribute embeddedAttribute = this;

            embeddedAttribute.editor.DrawEditorCombo(label, drawer, property, "asset");
        }
Beispiel #2
0
        internal override void Decorate(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
        {
            var enabled = true;

            if (_propertyName != null)
            {
                // Get the other property to be the predicate for the enabled/disabled state of this property.
                var otherProperty = property.serializedObject.FindProperty(_propertyName);
                if (otherProperty != null)
                {
                    enabled = GUIEnabled(otherProperty);
                }
            }

            if (_requiredComponentType != null && property.serializedObject.targetObject != null)
            {
                var comp = property.serializedObject.targetObject as Component;
                var enabledByComponent = comp.gameObject.TryGetComponent(_requiredComponentType, out _);
                if (_inverted)
                {
                    enabledByComponent = !enabledByComponent;
                }
                enabled = enabledByComponent && enabled;
            }

            GUI.enabled = enabled;
        }
Beispiel #3
0
 internal override void OnGUI(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
 {
     EditorGUI.PropertyField(position, property, label);
 }
Beispiel #4
0
        internal override void OnGUI(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
        {
            switch (property.propertyType)
            {
            case SerializedPropertyType.Float:
                EditorGUI.DelayedFloatField(position, property, label);
                break;

            case SerializedPropertyType.Integer:
                EditorGUI.DelayedIntField(position, property, label);
                break;

            case SerializedPropertyType.String:
                EditorGUI.DelayedTextField(position, property, label);
                break;

            default:
                EditorGUI.LabelField(position, label.text, "Delayed: must be float, integer, or string.");
                break;
            }
        }
Beispiel #5
0
 /// <summary>
 /// Override this method to additively change the appearance of a decorated field.
 /// </summary>
 internal abstract void Decorate(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer);
Beispiel #6
0
        internal override void OnGUI(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
        {
            switch (property.propertyType)
            {
            case SerializedPropertyType.Float:
                EditorGUI.Slider(position, property, minimum, maximum, label);
                break;

            case SerializedPropertyType.Integer:
                EditorGUI.IntSlider(position, property, (int)minimum, (int)maximum, label);
                break;

            default:
                EditorGUI.LabelField(position, label.text, "Range: must be float or integer.");
                break;
            }
        }
Beispiel #7
0
 internal override void OnGUI(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
 {
     property.intValue = EditorGUI.LayerField(position, label, property.intValue);
 }
Beispiel #8
0
        internal override void Decorate(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
        {
            if (visibility == Visibility.PropertyEnabled && !GUI.enabled || visibility == Visibility.PropertyDisabled && GUI.enabled)
            {
                return;
            }

            // Enable rich text in help boxes. Store original so we can revert since this might be a "hack".
            var style         = GUI.skin.GetStyle("HelpBox");
            var styleRichText = style.richText;

            style.richText = true;

            var height = style.CalcHeight(guiContent, EditorGUIUtility.currentViewWidth);

            if (height <= EditorGUIUtility.singleLineHeight)
            {
                // This gets internal layout of the help box right but breaks down if multiline.
                height += style.padding.horizontal + style.lineHeight;
            }

            // Always get a new control rect so we don't have to deal with positions and offsets.
            position = EditorGUILayout.GetControlRect(true, height, style);
            // + 1 maps our MessageType to Unity's.
            EditorGUI.HelpBox(position, message, (UnityEditor.MessageType)messageType + 1);

            // Revert skin since it persists.
            style.richText = styleRichText;
        }
        internal override void OnGUI(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
        {
            // Power provided so use PowerSlider.
            if (power != 1f)
            {
                if (property.propertyType != SerializedPropertyType.Float)
                {
                    // We could fallback to Slider, but better to raise an issue.
                    EditorGUI.LabelField(position, label.text, "Range: must be float if power is provided.");
                    return;
                }

                PowerSlider(position, property, minimum, maximum, power, label);
                return;
            }

            switch (property.propertyType)
            {
            case SerializedPropertyType.Float:
                EditorGUI.Slider(position, property, minimum, maximum, label);
                break;

            case SerializedPropertyType.Integer:
                EditorGUI.IntSlider(position, property, (int)minimum, (int)maximum, label);
                break;

            default:
                EditorGUI.LabelField(position, label.text, "Range: must be float or integer.");
                break;
            }
        }