| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using UnityEngine;
- namespace ET.Client
- {
- [EntitySystemOf(typeof(LSUnitViewComponent))]
- public static partial class LSUnitViewComponentSystem
- {
- [EntitySystem]
- private static void Awake(this LSUnitViewComponent self)
- {
- }
-
- [EntitySystem]
- private static void Destroy(this LSUnitViewComponent self)
- {
- }
- public static async ETTask InitAsync(this LSUnitViewComponent self)
- {
- Room room = self.Room();
- LSUnitComponent lsUnitComponent = room.LSWorld.GetComponent<LSUnitComponent>();
- Scene root = self.Root();
- foreach (long playerId in room.PlayerIds)
- {
- LSUnit lsUnit = lsUnitComponent.GetChild<LSUnit>(playerId);
- const string assetsName = $"Assets/Bundles/Unit/Unit.prefab";
- GameObject bundleGameObject = await room.GetComponent<ResourcesLoaderComponent>().LoadAssetsAsync(assetsName) as GameObject;
- GameObject prefab = bundleGameObject.Get<GameObject>("Skeleton");
- GlobalComponent globalComponent = root.GetComponent<GlobalComponent>();
- GameObject unitGo = UnityEngine.Object.Instantiate(prefab, globalComponent.Unit, true);
- unitGo.transform.position = lsUnit.Position.ToVector();
- LSUnitView lsUnitView = self.AddChildWithId<LSUnitView, GameObject>(lsUnit.Id, unitGo);
- lsUnitView.AddComponent<LSAnimatorComponent>();
- }
- }
- }
- }
|