GameDataMonitorMonitor.cs 1007 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class GameDataMonitor
  5. {
  6. #if UNITY_EDITOR
  7. static Dictionary<string, object> s_GameData = new Dictionary<string, object>();
  8. public static Dictionary<string, object> GameData
  9. {
  10. get { return GameDataMonitor.s_GameData; }
  11. set
  12. {
  13. GameDataMonitor.s_GameData = value;
  14. }
  15. }
  16. #endif
  17. public static void PushData(string dataKey,object obj)
  18. {
  19. #if UNITY_EDITOR
  20. if (!s_GameData.ContainsKey(dataKey))
  21. {
  22. s_GameData.Add(dataKey, obj);
  23. }
  24. else
  25. {
  26. s_GameData[dataKey] = obj;
  27. }
  28. #endif
  29. }
  30. public static void RemoveData(string dataKey)
  31. {
  32. #if UNITY_EDITOR
  33. if (s_GameData.ContainsKey(dataKey))
  34. {
  35. s_GameData.Remove(dataKey);
  36. }
  37. else
  38. {
  39. Debug.LogError("RemoveData dataKey dont exist ! ->" + dataKey + "<-");
  40. }
  41. #endif
  42. }
  43. }