AfterUnitCreate_CreateUnitView.cs 759 B

1234567891011121314151617181920
  1. using UnityEngine;
  2. namespace ET
  3. {
  4. public class AfterUnitCreate_CreateUnitView: AEvent<EventType.AfterUnitCreate>
  5. {
  6. public override async ETTask Run(EventType.AfterUnitCreate args)
  7. {
  8. // Unit View层
  9. ResourcesComponent resourcesComponent = Game.Scene.GetComponent<ResourcesComponent>();
  10. GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit");
  11. GameObject prefab = bundleGameObject.Get<GameObject>("Skeleton");
  12. GameObject go = UnityEngine.Object.Instantiate(prefab);
  13. GameObject.DontDestroyOnLoad(go);
  14. args.Unit.GameObject = go;
  15. args.Unit.AddComponent<AnimatorComponent>();
  16. }
  17. }
  18. }