AfterUnitCreate_CreateUnitView.cs 860 B

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