Skip to content

Instantly share code, notes, and snippets.

@inoook
Created January 31, 2017 12:31
Show Gist options
  • Save inoook/f0e0237cc0ca9af08f70f17fcfbf80e2 to your computer and use it in GitHub Desktop.
Save inoook/f0e0237cc0ca9af08f70f17fcfbf80e2 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
[ExecuteInEditMode]
public class EditorTemplate : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void Act()
{
Debug.Log("Act");
}
}
#if UNITY_EDITOR
[CustomEditor(typeof(EditorTemplate))]
class EditorTemplateEditor : Editor {
override public void OnInspectorGUI () {
EditorTemplate _target = (EditorTemplate)target;
if (GUILayout.Button ("Act")) {
_target.Act ();
}
if(_target != null){
DrawDefaultInspector();
EditorGUIUtility.labelWidth = 25;
EditorGUIUtility.fieldWidth = 50;
}
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment