TMPro_EventManager.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. namespace TMPro
  4. {
  5. public enum Compute_DistanceTransform_EventTypes { Processing, Completed };
  6. public static class TMPro_EventManager
  7. {
  8. public static readonly FastAction<object, Compute_DT_EventArgs> COMPUTE_DT_EVENT = new FastAction<object, Compute_DT_EventArgs>();
  9. // Event & Delegate used to notify TextMesh Pro objects that Material properties have been changed.
  10. public static readonly FastAction<bool, Material> MATERIAL_PROPERTY_EVENT = new FastAction<bool, Material>();
  11. public static readonly FastAction<bool, Object> FONT_PROPERTY_EVENT = new FastAction<bool, Object>();
  12. public static readonly FastAction<bool, Object> SPRITE_ASSET_PROPERTY_EVENT = new FastAction<bool, Object>();
  13. public static readonly FastAction<bool, Object> TEXTMESHPRO_PROPERTY_EVENT = new FastAction<bool, Object>();
  14. public static readonly FastAction<GameObject, Material, Material> DRAG_AND_DROP_MATERIAL_EVENT = new FastAction<GameObject, Material, Material>();
  15. public static readonly FastAction<bool> TEXT_STYLE_PROPERTY_EVENT = new FastAction<bool>();
  16. public static readonly FastAction<Object> COLOR_GRADIENT_PROPERTY_EVENT = new FastAction<Object>();
  17. public static readonly FastAction TMP_SETTINGS_PROPERTY_EVENT = new FastAction();
  18. public static readonly FastAction RESOURCE_LOAD_EVENT = new FastAction();
  19. public static readonly FastAction<bool, Object> TEXTMESHPRO_UGUI_PROPERTY_EVENT = new FastAction<bool, Object>();
  20. public static readonly FastAction<Object> TEXT_CHANGED_EVENT = new FastAction<Object>();
  21. //public static readonly FastAction WILL_RENDER_CANVASES = new FastAction();
  22. public static void ON_MATERIAL_PROPERTY_CHANGED(bool isChanged, Material mat)
  23. {
  24. MATERIAL_PROPERTY_EVENT.Call(isChanged, mat);
  25. }
  26. public static void ON_FONT_PROPERTY_CHANGED(bool isChanged, Object obj)
  27. {
  28. FONT_PROPERTY_EVENT.Call(isChanged, obj);
  29. }
  30. public static void ON_SPRITE_ASSET_PROPERTY_CHANGED(bool isChanged, Object obj)
  31. {
  32. SPRITE_ASSET_PROPERTY_EVENT.Call(isChanged, obj);
  33. }
  34. public static void ON_TEXTMESHPRO_PROPERTY_CHANGED(bool isChanged, Object obj)
  35. {
  36. TEXTMESHPRO_PROPERTY_EVENT.Call(isChanged, obj);
  37. }
  38. public static void ON_DRAG_AND_DROP_MATERIAL_CHANGED(GameObject sender, Material currentMaterial, Material newMaterial)
  39. {
  40. DRAG_AND_DROP_MATERIAL_EVENT.Call(sender, currentMaterial, newMaterial);
  41. }
  42. public static void ON_TEXT_STYLE_PROPERTY_CHANGED(bool isChanged)
  43. {
  44. TEXT_STYLE_PROPERTY_EVENT.Call(isChanged);
  45. }
  46. public static void ON_COLOR_GRADIENT_PROPERTY_CHANGED(Object obj)
  47. {
  48. COLOR_GRADIENT_PROPERTY_EVENT.Call(obj);
  49. }
  50. public static void ON_TEXT_CHANGED(Object obj)
  51. {
  52. TEXT_CHANGED_EVENT.Call(obj);
  53. }
  54. public static void ON_TMP_SETTINGS_CHANGED()
  55. {
  56. TMP_SETTINGS_PROPERTY_EVENT.Call();
  57. }
  58. public static void ON_RESOURCES_LOADED()
  59. {
  60. RESOURCE_LOAD_EVENT.Call();
  61. }
  62. public static void ON_TEXTMESHPRO_UGUI_PROPERTY_CHANGED(bool isChanged, Object obj)
  63. {
  64. TEXTMESHPRO_UGUI_PROPERTY_EVENT.Call(isChanged, obj);
  65. }
  66. //public static void ON_BASE_MATERIAL_CHANGED(Material mat)
  67. //{
  68. // BASE_MATERIAL_EVENT.Call(mat);
  69. //}
  70. //public static void ON_PROGRESSBAR_UPDATE(Progress_Bar_EventTypes event_type, Progress_Bar_EventArgs eventArgs)
  71. //{
  72. // if (PROGRESS_BAR_EVENT != null)
  73. // PROGRESS_BAR_EVENT(event_type, eventArgs);
  74. //}
  75. public static void ON_COMPUTE_DT_EVENT(object Sender, Compute_DT_EventArgs e)
  76. {
  77. COMPUTE_DT_EVENT.Call(Sender, e);
  78. }
  79. }
  80. public class Compute_DT_EventArgs
  81. {
  82. public Compute_DistanceTransform_EventTypes EventType;
  83. public float ProgressPercentage;
  84. public Color[] Colors;
  85. public Compute_DT_EventArgs(Compute_DistanceTransform_EventTypes type, float progress)
  86. {
  87. EventType = type;
  88. ProgressPercentage = progress;
  89. }
  90. public Compute_DT_EventArgs(Compute_DistanceTransform_EventTypes type, Color[] colors)
  91. {
  92. EventType = type;
  93. Colors = colors;
  94. }
  95. }
  96. }