CTT/Unity/Assets/HotfixView/Event/OnCreateNPCEvent.cs

29 lines
697 B
C#

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
{
Unit unit = args.unit;
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;
}
}
}