[Unity6] Custom Editor (Slider, HelpBox, Knob, ProgressBar)
์นดํ ๊ณ ๋ฆฌ: Go Unity
Slider
, HelpBox
, Knob
, IndentLevel
, ProgressBar
Slider
EditorGUILayout
int EditorGUILayout.IntSlider(string, int, int, int) : int ํ์
์ ๋ณ์๋ฅผ ์ฌ์ฉํ๋ Slider
float EditorGUILayout.FloatSlider(string, float, float, float) : float ํ์
์ ๋ณ์๋ฅผ ์ฌ์ฉํ๋ Slider
void EditorGUILayout.MinMaxSlider(string, ref float, ref float, float, float) : min ~ max ๋ฒ์์ ๊ฐ์ ์ ํํ ์ ์๋ Slider
ย
GUILayout
float GUILayout.HorizontalSlider(float, float, float) : float ํ์
๊ฐ๋ก Slider
float GUILayout.VerticalSlider(float, float, float) : float ํ์
์ธ๋ก Slider
Slider
intValue = EditorGUILayout.IntSlider("Int Slider", intValue, 0, 100);
floatValue = EditorGUILayout.Slider("Float Slider", floatValue, 0f, 10f);
EditorGUILayout.MinMaxSlider("MinMax Slider", ref minValue, ref maxValue, 0f, 10f);
floatValue = GUILayout.HorizontalSlider(floatValue, 0f, 10f);
floatValue = GUILayout.VerticalSlider(floatValue, 0f, 10f, GUILayout.Height(64));
HelpBox
Console View์ ๋ก๊ทธ๋ฅผ ์ถ๋ ฅํ๋ ๊ฒ๊ณผ ๊ฐ์ด ์ ๋ณด, ๊ฒฝ๊ณ , ์๋ฌ ๋ก๊ทธ๋ฅผ ์ถ๋ ฅํ๋ ๋ฐ์ค ์์ฑ
EditorGUILayout.HelpBox(string message, MessageType type);
HelpBox
EditorGUILayout.HelpBox("Info", MessageType.Info);
EditorGUILayout.HelpBox("Warning", MessageType.Warning);
EditorGUILayout.HelpBox("Error", MessageType.Error);
Knob
Drag๋ก ์กฐ์ ๊ฐ๋ฅํ ์ํ ๊ฒ์ด์ง
float result = EditorGUILayout.knob(Vector2 knobSize, float value, float minValue, float MaxValue, strin unit, Color backgroundColor, Color activeColor, bool showValue);
knobSize - ๊ฒ์ด์ง ํฌ๊ธฐ
unit - ์ถ๋ ฅํ ํ
์คํธ
showValue - ๊ฒ์ด์ง ์์น๋ฅผ ์ถ๋ ฅํ ์ง ์ฌ๋ถ
Knob
floatValue = EditorGUILayout.Knob(Vector2.one * 64, floatValue, 0f, 10f, "๊ฒ์ด์ง", Color.black, Color.red, true);
ProgressBar
0.0 ~ 1.0 ์ฌ์ด์ float ๋ฐ์ดํฐ๋ก ์งํ๋ ์ถ๋ ฅ.
ProgressBar ์ค์์ text ๋ด์ฉ ์ถ๋ ฅ
EditorGUI๋ก ์ฌ์ฉ ๊ฐ๋ฅ
void EditorGUI.ProgressBar(Rect position, float value, string text)
ProgressBar
Rect rect = new Rect(0, 400, 300, EditorGUIUtility.singleLineHeight);
EditorGUI.ProgressBar(rect, (float)intValue / 100, $"์ฒด๋ ฅ {intValue}/100");
์ด๊ฒ์ ๊ฒ ๋ฉ๋ชจ
IndentLevel
UI ๋ค์ฌ์ฐ๊ธฐ
int EditorGUI.indentLevel{set; get;}
IndentLevel
EditorGUI.indentLevel++;
EditorGUILayout.HelpBox("Info", MessageType.Info);
EditorGUI.indentLevel += 10;
EditorGUILayout.HelpBox("Warning", MessageType.Warning);
EditorGUI.indentLevel -= 11;
EditorGUILayout.HelpBox("Error", MessageType.Error);
์ก๋ด, ์ผ๊ธฐ?
Slider
, HelpBox
, Knob
, IndentLevel
, ProgressBar
๋๊ธ๋จ๊ธฐ๊ธฐ