少年修仙传客户端基础资源
dabaoji
2023-11-13 0a23e1b83f8fda8ab9f9e32fe71c26c431faf63a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using UnityEditor;
using UnityEngine;
 
namespace PigeonCoopToolkit.Utillities.Editor
{
    [CustomPropertyDrawer(typeof(Range))]
    public class RangePropertyDrawer : PropertyDrawer
    {
        public override void OnGUI(UnityEngine.Rect position, SerializedProperty property, UnityEngine.GUIContent label)
        {
            SerializedProperty Min = property.FindPropertyRelative("Min");
            SerializedProperty Max = property.FindPropertyRelative("Max");
            Vector2 newMinMax = Vector2.zero;
            position.height = 16;
            EditorGUI.LabelField(position, label);
            position.y += 20;
            position.width = position.width / 2;
            newMinMax.x = EditorGUI.FloatField(position, "Min", Min.floatValue);
            position.x += position.width;
            newMinMax.y = EditorGUI.FloatField(position, "Max", Max.floatValue);
 
            if (newMinMax.x > newMinMax.y)
                newMinMax.x = newMinMax.y;
 
            Min.floatValue = newMinMax.x;
            Max.floatValue = newMinMax.y;
        }
 
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            return base.GetPropertyHeight(property, label) + 20;
        }
    }
}