Example #1
0
        protected virtual void EmitPropertyField(Rect position, InspectableProperty targetInspectableProperty, GUIContent label)
        {
            var multiline = GetMultilineAttribute();

            if (multiline == null)
            {
                var range = GetRangeAttribute();
                if (range == null)
                {
                    EasyGUI.PropertyField(position, targetInspectableProperty, label, includeChildren: true);
                }
                else
                {
                    if (targetInspectableProperty.PropertyType == InspectablePropertyType.Float)
                    {
                        EasyGUI.Slider(position, targetInspectableProperty, range.Min, range.Max, label);
                    }
                    else if (targetInspectableProperty.PropertyType == InspectablePropertyType.Integer)
                    {
                        EasyGUI.IntSlider(position, targetInspectableProperty, (int)range.Min, (int)range.Max, label);
                    }
                    else
                    {
                        EditorGUI.LabelField(position, label.text, "Use Range with float or int.");
                    }
                }
            }
            else
            {
                var property = targetInspectableProperty;

                label = EasyGUI.BeginProperty(position, label, property);
                var method = typeof(EditorGUI).GetMethod("MultiFieldPrefixLabel", BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.NonPublic);
                position = (Rect)method.Invoke(null, new object[] { position, 0, label, 1 });

                EditorGUI.BeginChangeCheck();
                int indentLevel = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;
                var stringValue = EditorGUI.TextArea(position, property.StringValue);
                EditorGUI.indentLevel = indentLevel;
                if (EditorGUI.EndChangeCheck())
                {
                    property.StringValue = stringValue;
                }
                EasyGUI.EndProperty();
            }
        }
Example #2
0
        public override void OnGUI(Rect position, InspectableProperty property, GUIContent label)
        {
            RangeAttribute rangeAttribute = (RangeAttribute)base.Attribute;

            if (property.PropertyType == InspectablePropertyType.Float)
            {
                EasyGUI.Slider(position, property, rangeAttribute.min, rangeAttribute.max, label);
            }
            else if (property.PropertyType == InspectablePropertyType.Integer)
            {
                EasyGUI.IntSlider(position, property, (int)rangeAttribute.min, (int)rangeAttribute.max, label);
            }
            else
            {
                EditorGUI.LabelField(position, label.text, "Use Range with float or int.");
            }
        }