first
This commit is contained in:
8
Assets/02_Scripts/_Util/Editor.meta
Normal file
8
Assets/02_Scripts/_Util/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f216d086afefbc04bbc61ce6903c421a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Assets/02_Scripts/_Util/Editor/IntRangeDrawer.cs
Normal file
35
Assets/02_Scripts/_Util/Editor/IntRangeDrawer.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
// IntRange를 "라벨 [Min] ~ [Max]" 한 줄로 그린다.
|
||||
[CustomPropertyDrawer(typeof(IntRange))]
|
||||
public class IntRangeDrawer : PropertyDrawer
|
||||
{
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
=> EditorGUIUtility.singleLineHeight;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
position = EditorGUI.PrefixLabel(position, label);
|
||||
|
||||
int indent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0; // PrefixLabel 뒤 필드가 들여쓰기에 밀리지 않게
|
||||
|
||||
const float tildeWidth = 14f;
|
||||
float fieldWidth = (position.width - tildeWidth) * 0.5f;
|
||||
var minRect = new Rect(position.x, position.y, fieldWidth, position.height);
|
||||
var tildeRect = new Rect(minRect.xMax, position.y, tildeWidth, position.height);
|
||||
var maxRect = new Rect(tildeRect.xMax, position.y, fieldWidth, position.height);
|
||||
|
||||
EditorGUI.PropertyField(minRect, property.FindPropertyRelative("Min"), GUIContent.none);
|
||||
EditorGUI.LabelField(tildeRect, "~", CenteredLabel);
|
||||
EditorGUI.PropertyField(maxRect, property.FindPropertyRelative("Max"), GUIContent.none);
|
||||
|
||||
EditorGUI.indentLevel = indent;
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
|
||||
static GUIStyle _centered;
|
||||
static GUIStyle CenteredLabel => _centered ??= new GUIStyle(EditorStyles.label) { alignment = TextAnchor.MiddleCenter };
|
||||
}
|
||||
2
Assets/02_Scripts/_Util/Editor/IntRangeDrawer.cs.meta
Normal file
2
Assets/02_Scripts/_Util/Editor/IntRangeDrawer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 878034b1fe8afe64eaeb9b2e9b329778
|
||||
13
Assets/02_Scripts/_Util/IntRange.cs
Normal file
13
Assets/02_Scripts/_Util/IntRange.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
// 정수 범위 (양끝 포함). 인스펙터에서는 "라벨 [Min] ~ [Max]" 한 줄로 그려진다 (IntRangeDrawer).
|
||||
[Serializable]
|
||||
public struct IntRange
|
||||
{
|
||||
public int Min;
|
||||
public int Max;
|
||||
|
||||
public IntRange(int min, int max) { Min = min; Max = max; }
|
||||
|
||||
public bool Contains(int value) => value >= Min && value <= Max;
|
||||
}
|
||||
2
Assets/02_Scripts/_Util/IntRange.cs.meta
Normal file
2
Assets/02_Scripts/_Util/IntRange.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ca113007f09def4f82463aef8aca122
|
||||
Reference in New Issue
Block a user