Last active
January 23, 2022 15:10
-
-
Save kanonji/f0c02210739bf5e0cfdb5b2a568b554a to your computer and use it in GitHub Desktop.
Unityのエディタ拡張の書き始めに迷う時のテンプレート https://docs.unity3d.com/ja/current/ScriptReference/EditorGUILayout.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEditor; | |
using UnityEngine; | |
namespace Kanonji.Editor { | |
public class BarGenerator : EditorWindow { | |
private GameObject subject; | |
[MenuItem("Tools/BarGenerator")] | |
private static void Main() { | |
EditorWindow.GetWindow<BarGenerator>("BarGenerator"); | |
} | |
private void OnGUI() { | |
this.subject = EditorGUILayout.ObjectField(this.subject, typeof(Object), true) as GameObject; | |
if (GUILayout.Button("Do something")) { | |
this.DoSomething(); | |
} | |
} | |
private void DoSomething() { | |
Debug.Log(this.subject); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEngine.UIElements; | |
namespace Kanonji.CodeGeneration.Editor { | |
public class BazWindow : EditorWindow { | |
[MenuItem("Tools/Baz")] | |
public static void OpenWindow() => GetWindow<BazWindow>("Baz Window"); | |
public void OnEnable() { | |
var root = this.rootVisualElement; | |
var box = new Box(); | |
box.Add(new Button() { | |
text = "Example Button" | |
}); | |
box.Add(new Label() { | |
text = "Example Label" | |
}); | |
root.Add(box); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEditor; | |
using UnityEngine; | |
namespace Kanonji.Editor { | |
public class FooGenerator { | |
[MenuItem("Tools/FooGenerator")] | |
private static void Main() { | |
//Do something. | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment