Created
January 31, 2017 14:36
-
-
Save tsubaki/ca969c757923cc1d6c681e42296f7066 to your computer and use it in GitHub Desktop.
ScriptableSingletonを使用したケース
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 UnityEditor; | |
public class EditorWindowParameter : ScriptableSingleton<EditorWindowParameter> | |
{ | |
public EditorWindowTest window; | |
public string message; | |
} | |
public class EditorWindowTest : EditorWindow | |
{ | |
[MenuItem("Window/Show")] | |
static void Init() | |
{ | |
var instance = EditorWindowParameter.instance; | |
if (instance.window == null) { | |
instance.window = EditorWindow.CreateInstance<EditorWindowTest> (); | |
instance.message = "C"; | |
} | |
instance.window.Show (); | |
} | |
void OnGUI() | |
{ | |
var instance = EditorWindowParameter.instance; | |
GUILayout.Label (instance.message); | |
if (GUILayout.Button ("PUSH")) { instance.message += "#"; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment