using UnityEngine; namespace ET.Client { [Event(SceneType.Current)] public class OnNewZoneObject : AEvent { protected override async ETTask Run(Scene scene, EventType.OnNewZoneObject args) { var bo = args.Object; if(bo is BattleUnit) { await CreatUnitModel(bo as BattleUnit); } else { Log.Error("unknow new object"); } } private async ETTask CreatUnitModel(BattleUnit unit) { var zu = unit.ZUnit; var handle = await YooAssetProxy.LoadAssetAsync($"Unit_{zu.Info.FileName}"); var prefab = handle.GetAssetObject(); GameObject go = UnityEngine.Object.Instantiate(prefab, GlobalViewComponent.Instance.Unit, true); go.transform.position = new Vector3(0, 0, 0); go.transform.rotation = Quaternion.identity; ModelViewComponent.Instance.AddChildWithId(unit.Id, go, true); if (unit is BattleActor) { //相机跟随主角 //ModelViewComponent.Instance.AddComponent().Unit = unit; //固定视角相机 var camera = Camera.main; var pos = go.transform.position; camera.transform.position = new Vector3(pos.x, 7, pos.z - 15); } } } }