UIComponent.cs 690 B

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