| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using UnityEngine;
- namespace ET
- {
- public class CameraComponentAwakeSystem : AwakeSystem<CameraComponent>
- {
- public override void Awake(CameraComponent self)
- {
- self.Awake();
- }
- }
- public class CameraComponentLateUpdateSystem : LateUpdateSystem<CameraComponent>
- {
- public override void LateUpdate(CameraComponent self)
- {
- self.LateUpdate();
- }
- }
- public class CameraComponent : Entity
- {
- // 战斗摄像机
- public Camera mainCamera;
- public Unit Unit;
- public Camera MainCamera
- {
- get
- {
- return this.mainCamera;
- }
- }
- public void Awake()
- {
- this.mainCamera = Camera.main;
- }
- public void LateUpdate()
- {
- // 摄像机每帧更新位置
- UpdatePosition();
- }
- private void UpdatePosition()
- {
- Vector3 cameraPos = this.mainCamera.transform.position;
- this.mainCamera.transform.position = new Vector3(this.Unit.Position.x, cameraPos.y, this.Unit.Position.z - 1);
- }
- }
- }
|