12345678910111213141516171819202122232425262728293031323334 |
- using Mono;
- using UnityEngine;
- namespace ET.Client
- {
- [Event(SceneType.Current)]
- public class AfterUnitCreate_CreateUnitView : AEvent<EventType.AfterUnitCreate>
- {
- protected override async ETTask Run(Scene scene, EventType.AfterUnitCreate args)
- {
- Unit unit = args.Unit;
- // Unit View层
- var handle = await YooAssetProxy.LoadAssetAsync<GameObject>("Unit_Aj");
- var prefab = handle.GetAssetObject<GameObject>();
- 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<GameObjectComponent>().GameObject = go;
- var aniComp = unit.AddComponent<AnimatorComponent>();
- if (unit.IsActor)
- {
- //相机跟随主角
- //unit.AddComponent<CameraComponent>().Unit = unit;
- //固定视角相机
- var camera = Camera.main;
- camera.transform.position = new Vector3(unit.Position.x, 7, unit.Position.z - 15);
- }
- }
- }
- }
|