Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created August 20, 2015 17:09
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 tsubaki/61e9217e24c95376f3ae to your computer and use it in GitHub Desktop.
Save tsubaki/61e9217e24c95376f3ae to your computer and use it in GitHub Desktop.
ネストクラス(Monobehaviour)のサンプル
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