Created
April 30, 2019 08:28
-
-
Save sokuhatiku/d3063a9b916414196b316f9e0f943131 to your computer and use it in GitHub Desktop.
VitDeck GUI flow
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; | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
namespace VitDeck.Main | |
{ | |
public class Info | |
{ | |
public static event Action<Info> OnInstantiated; | |
public static Info Open() | |
{ | |
var instance = new Info(); | |
if (OnInstantiated != null) | |
OnInstantiated.Invoke(instance); | |
return instance; | |
} | |
} | |
} |
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; | |
using UnityEditor; | |
namespace VitDeck.Main.GUI | |
{ | |
public class InfoGUI : EditorWindow | |
{ | |
[SerializeField] | |
string instanceID = null; | |
[SerializeField] | |
string version = null; | |
[InitializeOnLoadMethod] | |
static void Bind() | |
{ | |
Info.OnInstantiated += Info_OnInstantiated; | |
} | |
private static void Info_OnInstantiated(Info obj) | |
{ | |
var gui = CreateInstance<InfoGUI>(); | |
gui.titleContent = new GUIContent("VitDeck Info"); | |
gui.Attach(obj); | |
gui.Show(); | |
} | |
private void Attach(Info instance) | |
{ | |
instanceID = "instanceID = " + instance.GetHashCode().ToString(); | |
version = "Version = " + VitDeck.Version; | |
} | |
private void OnGUI() | |
{ | |
EditorGUILayout.LabelField("VitDeck", EditorStyles.largeLabel); | |
EditorGUILayout.LabelField(instanceID); | |
EditorGUILayout.LabelField(version); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment