LSUnitViewComponentSystem.cs 1.0 KB

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