Created
January 31, 2017 12:31
-
-
Save inoook/f0e0237cc0ca9af08f70f17fcfbf80e2 to your computer and use it in GitHub Desktop.
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; | |
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