Created
July 26, 2020 01:29
-
-
Save afjk/0e25a5481348abcef1c7f80418a14bd7 to your computer and use it in GitHub Desktop.
エディタ拡張:Inspectorにボタンを表示して対象クラスのPublicメソッドを呼び出す
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
// 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