Skip to content

Instantly share code, notes, and snippets.

@afjk
Created July 26, 2020 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afjk/0e25a5481348abcef1c7f80418a14bd7 to your computer and use it in GitHub Desktop.
Save afjk/0e25a5481348abcef1c7f80418a14bd7 to your computer and use it in GitHub Desktop.
エディタ拡張:Inspectorにボタンを表示して対象クラスのPublicメソッドを呼び出す
// Editorフォルダ配下に配置
using UnityEditor;
using UnityEngine;
namespace STYLY
{
[CustomEditor(typeof(TargetClass))]
public class TargetClassInspector : Editor
{
public override void OnInspectorGUI()
{
var target = (TargetClass) target;
base.OnInspectorGUI();
var buttonEnabled = Application.isPlaying;
EditorGUI.BeginDisabledGroup(!buttonEnabled);
if (GUILayout.Button(("Run method1")))
{
target.Method1();
}
EditorGUI.EndDisabledGroup();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment