ํ ์คํธ์ ํฐํธ๋ฅผ ์ผ๊ด์ ์ผ๋ก ๋ฐ๊ฟ์ผ ํ ๋, ํน์ ๊ฐ์ฒด๋ฅผ ๋ชจ๋ ์ง์์ผํ ๋ ๋ฑ๋ฑ ๋ฌด์๋ฏธํ ๋ฐ๋ณต์์ ์ ์ํํด์ผ ํ๋ ๊ฒฝ์ฐ๊ฐ ์๋ค.
์ด๋ด ๋ Editor Programming์ ์ฌ์ฉํ๋ค๋ฉด ๋น ๋ฅด๊ณ ์ฝ๊ณ ์ ํํ๊ฒ ๋ณ๊ฒฝ์ด ๊ฐ๋ฅํ๋ค.
๋ ํจ์จ์ ์ธ ๊ฐ๋ฐ์ ์ํด์๋ ํ์๋ค !
1. ์๋จ ๋ฉ๋ด ์์ฑํ๊ณ ๋น Editor ํ๋ฉด ๋ง๋ค๊ธฐ
using UnityEditor;
public class MyEditorWindow : EditorWindow
{
[MenuItem("MyTool/Open MyTool %g")]
static void Open() {
var window = GetWindow<MyEditorWindow>();
window.title = "MyTool";
}
}
์๋จ์ MyTool ๋ฉ๋ด๋ฅผ ๋ง๋ค๊ณ ๋ฉ๋ด๋ฅผ ์ด๋ฉด Open MyTool ๋ฉ๋ด๊ฐ ์์ฑ๋๋ค.
๋จ์ถํค Command + g ๋ก ์ด์๋ ์๋ค.
ํด๋น ๋ฒํผ์ ๋๋ฅด๋ฉด Open ํจ์๊ฐ ์คํ๋๋ฉฐ Editor Window๋ฅผ ์ฐ๋ค.
Editor Window ์ ํ์ดํ์ MyTool์ด๋ค.
2. GUI(๋ผ๋ฒจ, ํ ์คํธ, ๋ฒํผ) ๋ง๋ค๊ธฐ
using UnityEngine;
using UnityEditor;
public class MyEditorWindow : EditorWindow
{
[MenuItem("MyTool/Open MyTool %g")]
static void Open() {
var window = GetWindow<MyEditorWindow>();
window.title = "MyTool";
}
private void OnGUI() {
EditorGUILayout.LabelField("Label!");
EditorGUILayout.TextField("Text!");
GUILayout.Button("Button");
}
}
์ฃผ์) EditorGUI ์ฝ๋๋ ์์ฝ๋ ํจ์(OnGUI)์์๋ง ์ฌ์ฉํด์ผ ํ๋ค.
GUI์ EditorGUI์ ์ฐจ์ด ?
GUI / GUILayout: Editor / ๋ฐํ์์ฉ
EditorGUI / EditorGUILayout: Only Editor
3. ๋ค์ํ GUI ๋ง๋ค๊ธฐ
using UnityEngine;
using UnityEditor;
public class MyEditorWindow : EditorWindow
{
int intValue;
float floatValue;
Color colorValue;
Gradient gradientValue = new Gradient();
Vector3 vector3Value;
Vector3Int vector3IntValue;
Rect rectValue;
Object objectValue;
string passwordValue;
string tagValue;
ParticleSystemCollisionType enumValue;
bool toggleValue;
string[] stringArr = new string[] { "String01", "String02", "String03", "String04", "String05", "String06" };
int selectionValue;
[MenuItem("MyTool/Open MyTool %g")]
static void Open() {
var window = GetWindow<MyEditorWindow>();
window.title = "MyTool";
}
private void OnGUI() {
#region EditorGUILayout
intValue = EditorGUILayout.IntField("Int๊ฐ", intValue);
floatValue = EditorGUILayout.FloatField("Float๊ฐ", floatValue);
colorValue = EditorGUILayout.ColorField("Color๊ฐ", colorValue);
gradientValue = EditorGUILayout.GradientField("Gradient๊ฐ", gradientValue);
vector3Value = EditorGUILayout.Vector3Field("Vector3๊ฐ", vector3Value);
vector3IntValue = EditorGUILayout.Vector3IntField("Vector3Int๊ฐ", vector3IntValue);
rectValue = EditorGUILayout.RectField("Rect๊ฐ", rectValue);
objectValue = EditorGUILayout.ObjectField("Object๊ฐ", objectValue, typeof(Object), false);
passwordValue = EditorGUILayout.PasswordField("Password๊ฐ", passwordValue);
tagValue = EditorGUILayout.TagField("tag๊ฐ", tagValue);
enumValue = (ParticleSystemCollisionType)EditorGUILayout.EnumFlagsField("Enum๊ฐ", enumValue);
floatValue = EditorGUILayout.Slider("Slider๊ฐ", floatValue, 0, 100);
EditorGUILayout.HelpBox("Help Box", MessageType.Error);
toggleValue = EditorGUILayout.Toggle("Toggle๊ฐ", toggleValue);
//์ค ๊ธ๊ธฐ
EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
#endregion
#region GUILayout
selectionValue = GUILayout.Toolbar(selectionValue, stringArr);
GUILayout.Space(15);
selectionValue = GUILayout.SelectionGrid(selectionValue, stringArr, 2);
GUILayout.Box(EditorGUIUtility.IconContent("Animation.Record"));
#endregion
}
}
๋งจ ๋ง์ง๋ง์ ์์ด์ฝ๋ชจ์์ ๋ ธ์ถ์ํค๋๊ฑด๋ฐ, ์๋ ์ฌ์ดํธ์ ๊ฐ๋ฉด ๋ค์ํ ๋ชจ์์ ์ฌ์ฉํ ์ ์๋ค.
https://github.com/halak/unity-editor-icons
GitHub - halak/unity-editor-icons
Contribute to halak/unity-editor-icons development by creating an account on GitHub.
github.com
Unity ๊ณต์ ๋ฌธ์ ์ฐธ๊ณ
https://docs.unity3d.com/ScriptReference/EditorGUILayout.html
Unity - Scripting API: EditorGUILayout
Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. Close
docs.unity3d.com
'๐ฎ Unity Study > Unity' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Unity] Texture Compression ๋ฐฉ์ (0) | 2023.04.13 |
---|---|
[Unity] Scriptable Object ์ฌ์ฉ๋ฒ, ์ฅ์ (0) | 2023.04.12 |
[Unity] Advanced InputField ์ฌ์ฉ๋ฒ (0) | 2023.02.01 |
[Unity] UGUI - Anchor(๊ธฐ์ค), Pivot(๋) (0) | 2022.12.15 |
[Unity LifeCycle] ์ ๋ํฐ ์๋ช ์ฃผ๊ธฐ (0) | 2022.12.01 |