LSUnitViewComponentSystem.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using UnityEngine;
  2. namespace ET.Client
  3. {
  4. [EntitySystemOf(typeof(LSUnitViewComponent))]
  5. public static partial class LSUnitViewComponentSystem
  6. {
  7. [EntitySystem]
  8. private static void Awake(this LSUnitViewComponent self)
  9. {
  10. Room room = self.Room();
  11. LSUnitComponent lsUnitComponent = room.LSWorld.GetComponent<LSUnitComponent>();
  12. Scene root = self.Root();
  13. foreach (long playerId in room.PlayerIds)
  14. {
  15. LSUnit lsUnit = lsUnitComponent.GetChild<LSUnit>(playerId);
  16. ResourcesComponent resourcesComponent = root.GetComponent<ResourcesComponent>();
  17. GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit");
  18. GameObject prefab = bundleGameObject.Get<GameObject>("Skeleton");
  19. GlobalComponent globalComponent = root.GetComponent<GlobalComponent>();
  20. GameObject unitGo = UnityEngine.Object.Instantiate(prefab, globalComponent.Unit, true);
  21. unitGo.transform.position = lsUnit.Position.ToVector();
  22. LSUnitView lsUnitView = self.AddChildWithId<LSUnitView, GameObject>(lsUnit.Id, unitGo);
  23. lsUnitView.AddComponent<LSAnimatorComponent>();
  24. }
  25. }
  26. [EntitySystem]
  27. private static void Destroy(this LSUnitViewComponent self)
  28. {
  29. }
  30. }
  31. }