Skip to content

Instantly share code, notes, and snippets.

@tsubaki tsubaki/InfomationMonitor
Last active Aug 11, 2017

Embed
What would you like to do?
ユーザーが登録した情報を表示 情報を更新すると一覧も更新
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class InfomationMonitor : SingletonMonoBehaviour<InfomationMonitor> {
public Dictionary<string, string> param = new Dictionary<string, string>();
private static bool monitorEnable = false;
void OnEnable()
{
monitorEnable = true;
}
void OnDisable()
{
monitorEnable = false;
param.Clear();
}
Vector2 scrollPositions = new Vector2(0,0);
void OnGUI()
{
scrollPositions = GUILayout.BeginScrollView(scrollPositions, GUILayout.Width(400), GUILayout.Height(80));
foreach( string key in param.Keys)
{
string message = string.Format("{0} : {1}", key, param[key]);
GUILayout.Label(message, GUILayout.Height(20));
}
GUILayout.EndScrollView();
}
public static void SetLabel(string key, string message)
{
if( !monitorEnable )
return;
if(! Instance.param.ContainsKey(key ))
{
Instance.param.Add(key, message);
}else{
Instance.param[key] = message;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.