Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active August 11, 2017 07:15
Show Gist options
  • Save tsubaki/4363841 to your computer and use it in GitHub Desktop.
Save tsubaki/4363841 to your computer and use it in GitHub Desktop.
ユーザーが登録した情報を表示 情報を更新すると一覧も更新
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