From cffe77a4cd72112529fa13029f7a3d62b98ed626 Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Sat, 30 Aug 2025 22:31:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=A2=84=E5=88=B6=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WindowsPlugins/Hierarchy Variant.prefab | 3 +- .../WindowsPlugins/Main Variant.prefab | 13 +--- .../[Runtime]/Camera/FreeSceneCamera.cs | 72 +++++++++++++++++++ .../[Runtime]/Camera/FreeSceneCamera.cs.meta | 11 +++ Convention/[Runtime]/File.cs | 5 +- Convention/[Runtime]/GlobalConfig.cs | 28 +++----- .../Variant/MainWindow/SceneGameWindow.cs | 2 +- Convention/[Visual]/[Prefabs]/Root.prefab | 59 ++++++++++----- 8 files changed, 142 insertions(+), 51 deletions(-) create mode 100644 Convention/[Runtime]/Camera/FreeSceneCamera.cs create mode 100644 Convention/[Runtime]/Camera/FreeSceneCamera.cs.meta diff --git a/Convention/Resources/WindowsPlugins/Hierarchy Variant.prefab b/Convention/Resources/WindowsPlugins/Hierarchy Variant.prefab index eb98dba..04dfaf9 100644 --- a/Convention/Resources/WindowsPlugins/Hierarchy Variant.prefab +++ b/Convention/Resources/WindowsPlugins/Hierarchy Variant.prefab @@ -549,7 +549,7 @@ MonoBehaviour: m_GameObject: {fileID: 2476344447420352570} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 91b5b0c662a658545ba5cfa5a0dd4b70, type: 3} + m_Script: {fileID: 11500000, guid: 21cd7907b9c0ce64bb4ef9dac9a93969, type: 3} m_Name: m_EditorClassIdentifier: --- !u!1 &2476344447420352570 stripped @@ -574,7 +574,6 @@ MonoBehaviour: m_TargetWindowContent: 0 m_ContentPlaneWhenNoWindow: {fileID: 0} ItemPrefab: {fileID: 2447206846939804910} - m_PerformanceMode: -1 --- !u!114 &5551824027870255850 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Convention/Resources/WindowsPlugins/Main Variant.prefab b/Convention/Resources/WindowsPlugins/Main Variant.prefab index dc340b3..5a409b9 100644 --- a/Convention/Resources/WindowsPlugins/Main Variant.prefab +++ b/Convention/Resources/WindowsPlugins/Main Variant.prefab @@ -249,17 +249,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 999be728ad5e8324baf45ccaf0f9c3d2, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!114 &62017277418570083 stripped -MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 5207688615231407609, guid: 14851ab435cb18448974bf76e92d8952, type: 3} - m_PrefabInstance: {fileID: 5231275486479271066} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8040840210842048516} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 21cd7907b9c0ce64bb4ef9dac9a93969, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!1 &1070298063421716900 stripped GameObject: m_CorrespondingSourceObject: {fileID: 5062977532320841022, guid: 14851ab435cb18448974bf76e92d8952, type: 3} @@ -309,7 +298,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2e5965b3e248d5743aec2dad26483515, type: 3} m_Name: m_EditorClassIdentifier: - m_WindowManager: {fileID: 62017277418570083} + m_WindowManager: {fileID: 0} m_root: {fileID: 1070298063421716900} m_planePath: moduleName: Game diff --git a/Convention/[Runtime]/Camera/FreeSceneCamera.cs b/Convention/[Runtime]/Camera/FreeSceneCamera.cs new file mode 100644 index 0000000..d681197 --- /dev/null +++ b/Convention/[Runtime]/Camera/FreeSceneCamera.cs @@ -0,0 +1,72 @@ +using System.Collections; +using System.Collections.Generic; +using Cinemachine; +using Convention.WindowsUI.Variant; +using UnityEngine; +using UnityEngine.InputSystem; + +namespace Convention +{ + public class FreeSceneCamera : MonoSingleton, ILoadedInHierarchy + { + [Resources, InspectorDraw(InspectorDrawType.Reference)] public Transform TargetFollow; + //[Resources, InspectorDraw(InspectorDrawType.Reference)] public CinemachineVirtualCamera VirtualCamera; + [Setting, InspectorDraw(InspectorDrawType.Text)] public float moveSpeed = 1; + [Setting, InspectorDraw(InspectorDrawType.Text)] public float rotationSpeed = 1; + private bool m_IsFocus = false; + [Setting, InspectorDraw(InspectorDrawType.Toggle)] + public bool isFocus + { + get => m_IsFocus; + set + { + if (m_IsFocus != value) + { + m_IsFocus = value; + Cursor.lockState = m_IsFocus ? CursorLockMode.Locked : CursorLockMode.None; + Cursor.visible = !m_IsFocus; + } + } + } + + private void Start() + { + m_IsFocus = false; + } + + private void Update() + { + Vector3 dxyz = Vector3.zero; + Vector3 rxyz = Vector3.zero; + if (Keyboard.current[Key.W].isPressed || Keyboard.current[Key.UpArrow].isPressed) + dxyz += TargetFollow.forward; + if (Keyboard.current[Key.A].isPressed || Keyboard.current[Key.LeftArrow].isPressed) + dxyz += -TargetFollow.right; + if (Keyboard.current[Key.D].isPressed || Keyboard.current[Key.RightArrow].isPressed) + dxyz += TargetFollow.right; + if (Keyboard.current[Key.S].isPressed || Keyboard.current[Key.DownArrow].isPressed) + dxyz += -TargetFollow.forward; + if (Keyboard.current[Key.Space].isPressed) + dxyz += TargetFollow.up; + if (Keyboard.current[Key.LeftShift].isPressed) + dxyz += -TargetFollow.up; + + var drotation = Vector3.zero; + if (isFocus) + { + var temp = Mouse.current.delta.ReadValue(); + drotation = new(-temp.y, temp.x, 0); + } + + // + + TargetFollow.Translate(dxyz * moveSpeed, Space.Self); + TargetFollow.Rotate(drotation * rotationSpeed, Space.Self); + + // + + if (Keyboard.current[Key.Escape].isPressed) + isFocus = false; + } + } +} diff --git a/Convention/[Runtime]/Camera/FreeSceneCamera.cs.meta b/Convention/[Runtime]/Camera/FreeSceneCamera.cs.meta new file mode 100644 index 0000000..546705a --- /dev/null +++ b/Convention/[Runtime]/Camera/FreeSceneCamera.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d8a335d6894daac4c980d4519ab1e3ac +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Convention/[Runtime]/File.cs b/Convention/[Runtime]/File.cs index a3dcd98..c10134e 100644 --- a/Convention/[Runtime]/File.cs +++ b/Convention/[Runtime]/File.cs @@ -287,7 +287,7 @@ namespace Convention { SaveAsText(JsonUtility.ToJson(data)); } - public void SaveAsJson(T data, string key) + public void SaveAsJson(T data, string key = "data") { ES3.Save(key, data,FullPath); } @@ -472,7 +472,8 @@ namespace Convention if (IsDir()) Directory.CreateDirectory(this.FullPath); else - File.Create(this.FullPath); + File.Create(this.FullPath).Close(); + Refresh(); } return this; } diff --git a/Convention/[Runtime]/GlobalConfig.cs b/Convention/[Runtime]/GlobalConfig.cs index 4cf8f18..59df067 100644 --- a/Convention/[Runtime]/GlobalConfig.cs +++ b/Convention/[Runtime]/GlobalConfig.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using UnityEngine; namespace Convention { @@ -14,14 +15,6 @@ namespace Convention ProjectConfig.InitExtensionEnv(); } - public static void GenerateEmptyConfigJson(ToolFile file) - { - file.SaveAsRawJson>(new() - { - { "properties",new Dictionary() } - }); - } - private int configLogging_tspace = "Property not found".Length; private ToolFile DataDir; @@ -46,7 +39,7 @@ namespace Convention // build up init data file var configFile = this.ConfigFile; if (configFile.Exists() == false) - GenerateEmptyConfigJson(configFile); + SaveProperties(); else if (isLoad) this.LoadProperties(); } @@ -133,13 +126,16 @@ namespace Convention } public int DataSize() => data_pair.Count; + [Serializable] + public class InternalProperty + { + public Dictionary property = new(); + } + public GlobalConfig SaveProperties() { var configFile = this.ConfigFile; - configFile.SaveAsRawJson>>(new() - { - { "properties", data_pair } - }); + configFile.SaveAsJson(new InternalProperty() { property = data_pair }); return this; } public GlobalConfig LoadProperties() @@ -151,11 +147,7 @@ namespace Convention } else { - var data = configFile.LoadAsRawJson>>(); - if (data.TryGetValue("properties", out data_pair) == false) - { - throw new Exception($"Can't find properties not found in config file"); - } + data_pair = configFile.LoadAsJson().property; } return this; } diff --git a/Convention/[Visual]/UIComponent/Variant/MainWindow/SceneGameWindow.cs b/Convention/[Visual]/UIComponent/Variant/MainWindow/SceneGameWindow.cs index 43240a6..e608f7f 100644 --- a/Convention/[Visual]/UIComponent/Variant/MainWindow/SceneGameWindow.cs +++ b/Convention/[Visual]/UIComponent/Variant/MainWindow/SceneGameWindow.cs @@ -15,7 +15,7 @@ namespace Convention.WindowsUI.Variant [Resources, SerializeField, OnlyNotNullMode(nameof(m_WindowManager)), TextArea(1, 3)] private string m_planePath; [Resources, SerializeField] private string moduleName = "Game"; [Resources, SerializeField,Header("Camera Base")] private CinemachineVirtualCameraBase SceneCamera; - [Resources, SerializeField] private CinemachineVirtualCameraBase ModuleCamera; + [Resources, SerializeField] public CinemachineVirtualCameraBase ModuleCamera; [Resources, SerializeField,HopeNotNull] private CinemachineBrain MainCamera; [Resources, SerializeField, OnlyNotNullMode] private RawImage TextureRenderer; [Resources, SerializeField] private GameObject m_GameObjectOnSceneOnly; diff --git a/Convention/[Visual]/[Prefabs]/Root.prefab b/Convention/[Visual]/[Prefabs]/Root.prefab index e52759f..99b64da 100644 --- a/Convention/[Visual]/[Prefabs]/Root.prefab +++ b/Convention/[Visual]/[Prefabs]/Root.prefab @@ -866,7 +866,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 20656b3ea2f18ff4cafeb3e072d97e01, type: 3} m_Name: m_EditorClassIdentifier: - Configs: [] + Configs: + - {fileID: 11400000, guid: 6ae7d35b7aadb144086c6fd47efa1f67, type: 2} --- !u!1 &6879896907576927809 GameObject: m_ObjectHideFlags: 0 @@ -1381,8 +1382,8 @@ GameObject: - component: {fileID: 257072955588997064} - component: {fileID: 7206794941111705965} - component: {fileID: 6620572890770901228} - - component: {fileID: 296421685682893814} - component: {fileID: 5183958985083021394} + - component: {fileID: 5016912336678498821} m_Layer: 0 m_Name: SceneVirtualCamera m_TagString: Untagged @@ -1541,19 +1542,6 @@ MonoBehaviour: m_MipBias: 0 m_VarianceClampScale: 0.9 m_ContrastAdaptiveSharpening: 0 ---- !u!114 &296421685682893814 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8936143318184057326} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 20656b3ea2f18ff4cafeb3e072d97e01, type: 3} - m_Name: - m_EditorClassIdentifier: - Configs: [] --- !u!114 &5183958985083021394 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1566,6 +1554,21 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: b9daa10f8493ef343892b18ea5365cf7, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &5016912336678498821 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8936143318184057326} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d8a335d6894daac4c980d4519ab1e3ac, type: 3} + m_Name: + m_EditorClassIdentifier: + TargetFollow: {fileID: 8045550196878911107} + moveSpeed: 1 + rotationSpeed: 1 --- !u!1 &9093688029225793428 GameObject: m_ObjectHideFlags: 0 @@ -1985,7 +1988,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6988049406595588431, guid: 9d6ed184d3a99cd49b371b22fec6714f, type: 3} propertyPath: m_Value - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 8180581102036933126, guid: 9d6ed184d3a99cd49b371b22fec6714f, type: 3} propertyPath: m_Name @@ -2189,6 +2192,26 @@ PrefabInstance: propertyPath: m_Name value: Main objectReference: {fileID: 0} + - target: {fileID: 9148145088215354980, guid: de9a9a57b2b5472478e3a8bf12c38e87, type: 3} + propertyPath: clickEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Mode + value: 6 + objectReference: {fileID: 0} + - target: {fileID: 9148145088215354980, guid: de9a9a57b2b5472478e3a8bf12c38e87, type: 3} + propertyPath: clickEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Target + value: + objectReference: {fileID: 5016912336678498821} + - target: {fileID: 9148145088215354980, guid: de9a9a57b2b5472478e3a8bf12c38e87, type: 3} + propertyPath: clickEvent.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName + value: set_isFocus + objectReference: {fileID: 0} + - target: {fileID: 9148145088215354980, guid: de9a9a57b2b5472478e3a8bf12c38e87, type: 3} + propertyPath: clickEvent.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName + value: Convention.FreeSceneCamera, Assembly-CSharp + objectReference: {fileID: 0} + - target: {fileID: 9148145088215354980, guid: de9a9a57b2b5472478e3a8bf12c38e87, type: 3} + propertyPath: clickEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_BoolArgument + value: 1 + objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] @@ -2572,6 +2595,10 @@ PrefabInstance: propertyPath: m_sharedMaterial value: objectReference: {fileID: -6641050763205051922, guid: 4abb91c83e9e6214992ef15922294c0c, type: 2} + - target: {fileID: 4422343518200301270, guid: 47ed122beb336ff4ba830546f35ad2c8, type: 3} + propertyPath: m_hasFontAssetChanged + value: 0 + objectReference: {fileID: 0} - target: {fileID: 5981089689042882848, guid: 47ed122beb336ff4ba830546f35ad2c8, type: 3} propertyPath: m_PropertiesWindow value: