열차 목업의 내부 확인용 프로젝트
smchoi
2024-07-31 9fe33c1ae076b0f6501619388e6b4cc872b76f80
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
35
36
37
38
39
40
41
42
43
44
45
46
//////////////////////////////////////////////////////
// MK Glow Range Drawer                                   //
//                                                    //
// Created by Michael Kremmel                       //
// www.michaelkremmel.de                            //
// Copyright © 2020 All rights reserved.            //
//////////////////////////////////////////////////////
 
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
 
namespace MK.Glow.Legacy.Editor
{
    [CustomPropertyDrawer(typeof(MinMaxRangeAttribute))]
    internal class MinMaxRangeDrawer : PropertyDrawer
    {
        public override void OnGUI( Rect startRect, SerializedProperty property, GUIContent label )
        {
            EditorGUI.BeginProperty(startRect, label, property);
            MinMaxRangeAttribute range = attribute as MinMaxRangeAttribute;
            SerializedProperty minRange = property.FindPropertyRelative("minValue");
            SerializedProperty maxRange = property.FindPropertyRelative("maxValue");
            float minValue = minRange.floatValue;
            float maxValue = maxRange.floatValue;
 
            Rect minRect = new Rect(EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth * 0.33f, startRect.y, EditorGUIUtility.fieldWidth, startRect.height);
            float p = minRect.x + EditorGUIUtility.standardVerticalSpacing * 2f + EditorGUIUtility.fieldWidth;
            Rect sliderRect = new Rect(p, startRect.y, startRect.width - p - EditorGUIUtility.fieldWidth + EditorGUIUtility.standardVerticalSpacing * 5f, startRect.height);
            Rect maxRect = new Rect(sliderRect.x + sliderRect.width + EditorGUIUtility.standardVerticalSpacing * 2f, startRect.y, EditorGUIUtility.fieldWidth, startRect.height);
 
            EditorGUI.LabelField(startRect, label);
            minValue = EditorGUI.FloatField(minRect, minValue);
 
            EditorGUI.MinMaxSlider(sliderRect, ref minValue, ref maxValue, range.minLimit, range.maxLimit);
            maxValue = EditorGUI.FloatField(maxRect, maxValue);
 
            minRange.floatValue = minValue;
            maxRange.floatValue = maxValue;
            EditorGUI.EndProperty();
        }
    }
}
#endif