Browse Source

相机自适应

master
jiannan.guo@yingxiong.com 1 month ago
parent
commit
a444683c9e
  1. 39
      client/client/Assets/Scripts/CoreGame/AFramSync/Render/Component/Proxy/VirtualCameraProxy.cs
  2. 3
      client/client/Assets/Scripts/CoreGame/AFramSync/Render/Service/REntityCreatorSvc.cs
  3. 2
      client/client/Assets/Scripts/CoreGame/AFramSync/Render/System/Camera/CameraFeature.cs

39
client/client/Assets/Scripts/CoreGame/AFramSync/Render/Component/Proxy/VirtualCameraProxy.cs

@ -8,6 +8,7 @@ namespace CoreGame.Render
{ {
// public CinemachineVirtualCamera virtualCamera; // public CinemachineVirtualCamera virtualCamera;
// public CinemachineBrain brain; // public CinemachineBrain brain;
private Camera m_Camera;
private Transform m_Target; private Transform m_Target;
internal Vector3 followPos; internal Vector3 followPos;
@ -21,12 +22,12 @@ namespace CoreGame.Render
// todo 需要加绑点 // todo 需要加绑点
protected override void Initialize(GameObject go, RenderEntity ent) protected override void Initialize(GameObject go, RenderEntity ent)
{ {
m_Camera = Camera.main;
// this.virtualCamera = go.GetComponentsInChildren<CinemachineVirtualCamera>()[0]; // this.virtualCamera = go.GetComponentsInChildren<CinemachineVirtualCamera>()[0];
// brain = Camera.main.gameObject.GetComponent<CinemachineBrain>(); // brain = Camera.main.gameObject.GetComponent<CinemachineBrain>();
hasSynced = false; hasSynced = false;
// virtualCamera.m_Lens.OrthographicSize = 8.5f; //调整相机大小 // virtualCamera.m_Lens.OrthographicSize = 8.5f; //调整相机大小
// m_CachePos = brain.OutputCamera.transform.position; m_Size = m_Camera.orthographicSize;
// m_Size = virtualCamera.m_Lens.OrthographicSize;
// var componentsInChildren = go.GetComponentsInChildren<Transform>(); // var componentsInChildren = go.GetComponentsInChildren<Transform>();
// for (int i = 0; i < componentsInChildren.Length; i++) // for (int i = 0; i < componentsInChildren.Length; i++)
// { // {
@ -42,24 +43,24 @@ namespace CoreGame.Render
public override void Sync2Mono() public override void Sync2Mono()
{ {
// if (isInited == false) if (isInited == false)
// return; return;
//
// var brainOutputCamera = brain.OutputCamera; var brainOutputCamera = m_Camera;
// brainOutputCamera.transform.position = new Vector3(followPos.x, followPos.y, m_CachePos.z); // brainOutputCamera.transform.position = new Vector3(followPos.x, followPos.y, m_CachePos.z);
// hasSynced = true; hasSynced = true;
// var width = Screen.width; var width = Screen.width;
// var height = Screen.height; var height = Screen.height;
// if (width == m_Width && height == m_Height) if (width == m_Width && height == m_Height)
// return; return;
//
// m_Width = width; m_Width = width;
// m_Height = height; m_Height = height;
// var f = height * 1.0f / width; var f = height * 1.0f / width;
// if (f > m_NormalRatio) if (f > m_NormalRatio)
// { {
// brainOutputCamera.orthographicSize = m_Size * f / m_NormalRatio; brainOutputCamera.orthographicSize = m_Size * f / m_NormalRatio;
// } }
} }
} }
} }

3
client/client/Assets/Scripts/CoreGame/AFramSync/Render/Service/REntityCreatorSvc.cs

@ -75,7 +75,8 @@ namespace CoreGame.Render
path = prefabPath, path = prefabPath,
scaleParam = 1, scaleParam = 1,
}, null); }, null);
// entity.AddVirtualCameraProxy(null, null, entity); entity.AddVirtualCameraProxy(entity);
entity.virtualCameraProxy.Init(null, entity);
return entity; return entity;
} }

2
client/client/Assets/Scripts/CoreGame/AFramSync/Render/System/Camera/CameraFeature.cs

@ -8,7 +8,7 @@ namespace CoreGame.Render
public CameraFeature(Injector injector) : base(injector) public CameraFeature(Injector injector) : base(injector)
{ {
// Add(new CameraShakeSystem()); // Add(new CameraShakeSystem());
// Add(new CameraSyncSystem()); Add(new CameraSyncSystem());
} }
} }
} }
Loading…
Cancel
Save