UI.cs 768 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using UnityEngine;
  2. namespace Model
  3. {
  4. public sealed class UI: Entity
  5. {
  6. public Scene Scene { get; set; }
  7. public UIType UIType { get; }
  8. public string Name
  9. {
  10. get
  11. {
  12. return this.GameObject.name;
  13. }
  14. }
  15. public GameObject GameObject { get; }
  16. public override void Dispose()
  17. {
  18. if (this.Id == 0)
  19. {
  20. return;
  21. }
  22. base.Dispose();
  23. }
  24. public void SetAsFirstSibling()
  25. {
  26. this.GameObject.transform.SetAsFirstSibling();
  27. }
  28. public UI(Scene scene, UIType uiType, UI parent, GameObject gameObject) : base(EntityType.UI)
  29. {
  30. this.Scene = scene;
  31. this.UIType = uiType;
  32. gameObject.transform.SetParent(parent?.GameObject.transform);
  33. this.GameObject = gameObject;
  34. this.AddComponent<ChildrenComponent<UI>>();
  35. }
  36. }
  37. }