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