using System; #if UNITY_EDITOR using UnityEditor; using UnityEngine; [CustomPropertyDrawer(typeof(CLabelAttribute))] public class CLabelPropertyDrawer : PropertyDrawer { public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { CLabelAttribute labelAttribute = (CLabelAttribute)attribute; label.text = labelAttribute.label; // 커스텀 레이블로 텍스트 변경 EditorGUI.PropertyField(position, property, label); } } [CustomPropertyDrawer(typeof(CLabeledRangeAttribute))] public class LabeledRangeDrawer : PropertyDrawer { public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { CLabeledRangeAttribute range = (CLabeledRangeAttribute)attribute; // 기본 레이블을 이용해서 새로운 레이블을 설정 EditorGUI.BeginProperty(position, label, property); // 범위 슬라이더 UI if (property.propertyType == SerializedPropertyType.Float) { EditorGUI.Slider(position, property, range.min, range.max, new GUIContent(range.label)); } else if (property.propertyType == SerializedPropertyType.Integer) { EditorGUI.IntSlider(position, property, (int)range.min, (int)range.max, new GUIContent(range.label)); } EditorGUI.EndProperty(); } } #endif public class CLabelAttribute : PropertyAttribute { public string label; public CLabelAttribute(string label) { this.label = label; } } public class CLabeledRangeAttribute : PropertyAttribute { public string label; public float min; public float max; public CLabeledRangeAttribute(string label, float min, float max) { this.label = label; this.min = min; this.max = max; } }