From 1436080fd6d56c1aa8821ddef47f53b024a1987f Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Thu, 18 Dec 2025 10:16:24 +0800 Subject: [PATCH] CameraObject --- Assets/Scripts/Framework/CameraObject.cs | 39 +++++++++--------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/Assets/Scripts/Framework/CameraObject.cs b/Assets/Scripts/Framework/CameraObject.cs index c942b72..b5c2239 100644 --- a/Assets/Scripts/Framework/CameraObject.cs +++ b/Assets/Scripts/Framework/CameraObject.cs @@ -9,6 +9,7 @@ using UnityEngine; using Demo.Game.Attr; using System.IO; using Convention; +using Demo.Game.ConfigType; namespace Demo.Game { @@ -62,6 +63,10 @@ namespace Demo.Game [Scriptable(nameof(MakeCameraObject))] public class CameraObject : ScriptableObject { + protected override ScriptLoadableConfig MakeConfig() + { + return new CameraObjectConfig(); + } private Camera MainCamera => Camera.main; private CinemachineCamera m_VirtualCamera; private CinemachineCamera VirtualCamera @@ -100,7 +105,7 @@ namespace Demo.Game [Convention.RScript.Variable.Attr.Method] public void SetOrthographic(bool orthographic) { - MainCamera.orthographic = orthographic; + GetConfig().orthographic = MainCamera.orthographic = orthographic; } /// @@ -109,7 +114,7 @@ namespace Demo.Game [Convention.RScript.Variable.Attr.Method] public void SetFieldOfView(float fieldOfView) { - MainCamera.fieldOfView = fieldOfView; + GetConfig().fieldOfView = MainCamera.fieldOfView = fieldOfView; } /// @@ -118,7 +123,7 @@ namespace Demo.Game [Convention.RScript.Variable.Attr.Method] public void SetOrthographicSize(float orthographicSize) { - MainCamera.orthographicSize = orthographicSize; + GetConfig().orthographicSize = MainCamera.orthographicSize = orthographicSize; } /// @@ -127,7 +132,7 @@ namespace Demo.Game [Convention.RScript.Variable.Attr.Method] public void SetNearClipPlane(float nearClipPlane) { - MainCamera.nearClipPlane = nearClipPlane; + GetConfig().nearClipPlane = MainCamera.nearClipPlane = nearClipPlane; } /// @@ -136,7 +141,7 @@ namespace Demo.Game [Convention.RScript.Variable.Attr.Method] public void SetFarClipPlane(float farClipPlane) { - MainCamera.farClipPlane = farClipPlane; + GetConfig().farClipPlane = MainCamera.farClipPlane = farClipPlane; } /// @@ -145,7 +150,7 @@ namespace Demo.Game [Convention.RScript.Variable.Attr.Method] public void SetDepth(float depth) { - MainCamera.depth = depth; + GetConfig().depth = MainCamera.depth = depth; } /// @@ -154,6 +159,7 @@ namespace Demo.Game [Convention.RScript.Variable.Attr.Method] public void SetVirtualCameraFollow(ScriptableObject target) { + GetConfig().VirtualCameraFollow = GetRoot().FindIndex(target); VirtualCamera.Follow = target.transform; } @@ -163,6 +169,7 @@ namespace Demo.Game [Convention.RScript.Variable.Attr.Method] public void SetVirtualCameraLookAt(ScriptableObject target) { + GetConfig().VirtualCameraLookAt = GetRoot().FindIndex(target); VirtualCamera.LookAt = target.transform; } @@ -178,28 +185,11 @@ namespace Demo.Game var body = VirtualCamera.GetCinemachineComponent(CinemachineCore.Stage.Body) as CinemachineFollow; if (body != null) { + GetConfig().VirtualCameraFollowOffset = new Vector3(x, y, z); body.FollowOffset = new Vector3(x, y, z); } } - /// - /// 设置虚拟相机跟随阻尼 - /// - /// X轴阻尼 - /// Y轴阻尼 - /// Z轴阻尼 - //[Convention.RScript.Variable.Attr.Method] - //public void SetVirtualCameraFollowDamping(float x, float y, float z) - //{ - // var body = VirtualCamera.GetCinemachineComponent(CinemachineCore.Stage.Body) as CinemachineFollow; - // if (body != null) - // { - // body.XDamping = x; - // body.YDamping = y; - // body.ZDamping = z; - // } - //} - /// /// 设置虚拟相机观察阻尼 /// @@ -212,6 +202,7 @@ namespace Demo.Game var aim = VirtualCamera.GetCinemachineComponent(CinemachineCore.Stage.Body) as CinemachineRotationComposer; if (aim != null) { + GetConfig().VirtualCameraLookAtDamping = new Vector3(x, y, z); aim.Damping = new(x, y); } }