using Mono; using UnityEngine; namespace ET.Client { [Event(SceneType.Current)] public class AfterUnitCreate_CreateUnitView : AEvent { protected override async ETTask Run(Scene scene, EventType.AfterUnitCreate args) { Unit unit = args.Unit; // Unit View层 var handle = await YooAssetProxy.LoadAssetAsync("Unit_Aj"); var prefab = handle.GetAssetObject(); GameObject go = UnityEngine.Object.Instantiate(prefab, GlobalComponent.Instance.Unit, true); Log.Debug($"loaded unit({unit.Id}) model: Unit_Aj"); go.transform.position = unit.Position; unit.AddComponent().GameObject = go; var aniComp = unit.AddComponent(); if (unit.IsActor) { //相机跟随主角 //unit.AddComponent().Unit = unit; //固定视角相机 var camera = Camera.main; camera.transform.position = new Vector3(unit.Position.x, 7, unit.Position.z - 15); } } } }