AfterUnitCreate_CreateUnitView.cs 900 B

12345678910111213141516171819202122
  1. using UnityEngine;
  2. namespace ET.Client
  3. {
  4. [Event(SceneType.Current)]
  5. public class AfterUnitCreate_CreateUnitView: AEvent<Unit, EventType.AfterUnitCreate>
  6. {
  7. protected override async ETTask Run(Unit unit, EventType.AfterUnitCreate args)
  8. {
  9. // Unit View层
  10. // 这里可以改成异步加载,demo就不搞了
  11. GameObject bundleGameObject = (GameObject)ResourcesComponent.Instance.GetAsset("Unit.unity3d", "Unit");
  12. GameObject prefab = bundleGameObject.Get<GameObject>("Skeleton");
  13. GameObject go = UnityEngine.Object.Instantiate(prefab, GlobalComponent.Instance.Unit, true);
  14. go.transform.position = unit.Position;
  15. unit.AddComponent<GameObjectComponent>().GameObject = go;
  16. unit.AddComponent<AnimatorComponent>();
  17. await ETTask.CompletedTask;
  18. }
  19. }
  20. }