2021-04-08 20:09:59 +08:00
|
|
|
|
using ET.EventType;
|
|
|
|
|
using ET;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
public class OnCreateNPCEvent : AEvent<OnCreateUNPC>
|
|
|
|
|
{
|
|
|
|
|
public override async ETTask Run(OnCreateUNPC args)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
Unit unit = args.unit;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
GameObject go = (await ResourceViewHelper.LoadPrefabAsync(args.prefabId)).gameObject;
|
|
|
|
|
unit.AddComponent<UnitView, GameObject>(go);
|
|
|
|
|
|
|
|
|
|
NPCHudComponent.Instance.Init(unit);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
await ETTask.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|