UIComponent.cs 704 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.Collections.Generic;
  2. namespace ET
  3. {
  4. [ObjectSystem]
  5. public class UIComponentAwakeSystem : AwakeSystem<UIComponent>
  6. {
  7. public override void Awake(UIComponent self)
  8. {
  9. }
  10. }
  11. /// <summary>
  12. /// 管理所有UI
  13. /// </summary>
  14. public class UIComponent: Entity
  15. {
  16. public Dictionary<string, UI> uis = new Dictionary<string, UI>();
  17. public void Add(UI ui)
  18. {
  19. this.uis.Add(ui.Name, ui);
  20. ui.Parent = this;
  21. }
  22. public void Remove(string name)
  23. {
  24. if (!this.uis.TryGetValue(name, out UI ui))
  25. {
  26. return;
  27. }
  28. this.uis.Remove(name);
  29. ui.Dispose();
  30. }
  31. public UI Get(string name)
  32. {
  33. UI ui = null;
  34. this.uis.TryGetValue(name, out ui);
  35. return ui;
  36. }
  37. }
  38. }