Created
August 20, 2015 17:09
-
-
Save tsubaki/61e9217e24c95376f3ae to your computer and use it in GitHub Desktop.
ネストクラス(Monobehaviour)のサンプル
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 UnityEngine; | |
using System.Collections; | |
#if UNITY_EDITOR | |
using UnityEditor; | |
#endif | |
public class SampleCode : MonoBehaviour | |
{ | |
[SerializeField, HideInInspector] | |
string label = "none"; | |
private void Init() | |
{ | |
label = System.DateTime.Now.ToString (); | |
} | |
#if UNITY_EDITOR | |
[CustomEditor(typeof(SampleCode))] | |
class SampleCodeEditor : Editor | |
{ | |
public override void OnInspectorGUI () | |
{ | |
EditorGUILayout.LabelField (Instance.label); | |
if (GUILayout.Button ("Init")) { | |
Instance.Init(); | |
} | |
} | |
SampleCode Instance { | |
get{ return (SampleCode)target; } | |
} | |
} | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment