Skip to content

Instantly share code, notes, and snippets.

@kanonji
Last active January 23, 2022 15:10
Show Gist options
  • Save kanonji/f0c02210739bf5e0cfdb5b2a568b554a to your computer and use it in GitHub Desktop.
Save kanonji/f0c02210739bf5e0cfdb5b2a568b554a to your computer and use it in GitHub Desktop.
Unityのエディタ拡張の書き始めに迷う時のテンプレート https://docs.unity3d.com/ja/current/ScriptReference/EditorGUILayout.html
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);
}
}
}
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);
}
}
}
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