MainMapUIView.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using FairyGUI;
  2. using UnityEngine;
  3. using XGame.Framework.Map;
  4. using XGame.Framework.ObjectCollection;
  5. namespace FL.Map.UI
  6. {
  7. public class MainMapUIView : EntityView<MainMapUIVM>
  8. {
  9. public Transform CombatValRoot => VM.CombatValRoot;
  10. public Transform PlayerRoot => VM.PlayerRoot;
  11. public Transform MonsterRoot => VM.MonsterRoot;
  12. protected override void OnEnable(object intent)
  13. {
  14. VM.Canvas.worldCamera = StageCamera.main;
  15. }
  16. protected override void OnDisable()
  17. {
  18. VM.Canvas.worldCamera = null;
  19. }
  20. }
  21. public class MainMapUIVM : EntityViewModel
  22. {
  23. public Canvas Canvas { get; private set; }
  24. public Transform MonsterRoot { get; private set; }
  25. public Transform PlayerRoot { get; private set; }
  26. public Transform CombatValRoot { get; private set; }
  27. protected override void OnInit(IObjectCollector collector)
  28. {
  29. Canvas = collector.GetComponent<Canvas>("Canvas");
  30. MonsterRoot = collector.GetGameObject("MonsterRoot").transform;
  31. PlayerRoot = collector.GetGameObject("PlayerRoot").transform;
  32. CombatValRoot = collector.GetGameObject("CombatValRoot").transform;
  33. }
  34. }
  35. }