From a444683c9e1b087ef96b124f82267b7b809c58e6 Mon Sep 17 00:00:00 2001 From: "jiannan.guo@yingxiong.com" Date: Fri, 25 Jul 2025 20:36:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B8=E6=9C=BA=E8=87=AA=E9=80=82=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Component/Proxy/VirtualCameraProxy.cs | 39 ++++++++++--------- .../Render/Service/REntityCreatorSvc.cs | 3 +- .../Render/System/Camera/CameraFeature.cs | 2 +- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/client/client/Assets/Scripts/CoreGame/AFramSync/Render/Component/Proxy/VirtualCameraProxy.cs b/client/client/Assets/Scripts/CoreGame/AFramSync/Render/Component/Proxy/VirtualCameraProxy.cs index 98b9f6fd..0bb91265 100644 --- a/client/client/Assets/Scripts/CoreGame/AFramSync/Render/Component/Proxy/VirtualCameraProxy.cs +++ b/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()[0]; // brain = Camera.main.gameObject.GetComponent(); 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(); // 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; + } } } } \ No newline at end of file diff --git a/client/client/Assets/Scripts/CoreGame/AFramSync/Render/Service/REntityCreatorSvc.cs b/client/client/Assets/Scripts/CoreGame/AFramSync/Render/Service/REntityCreatorSvc.cs index fe844e23..ed965ad1 100644 --- a/client/client/Assets/Scripts/CoreGame/AFramSync/Render/Service/REntityCreatorSvc.cs +++ b/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; } diff --git a/client/client/Assets/Scripts/CoreGame/AFramSync/Render/System/Camera/CameraFeature.cs b/client/client/Assets/Scripts/CoreGame/AFramSync/Render/System/Camera/CameraFeature.cs index ecae3d42..4c72739e 100644 --- a/client/client/Assets/Scripts/CoreGame/AFramSync/Render/System/Camera/CameraFeature.cs +++ b/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()); } } } \ No newline at end of file