From 045218dc9fb60c5f0e1f412de747cd7a8b2912fd Mon Sep 17 00:00:00 2001 From: Thorbjoern Date: Mon, 2 Jun 2025 20:13:25 +0200 Subject: [PATCH] Optimized Oribit Camera in Replay, now only moving with right click --- Assets/MetaXR/MetaXRProjectSettings.asset | 3 +- Assets/_Scenes/TrainingObserverMeta.unity | 40 +++++++++++++------ .../Utility/OrbitCameraMouseControl.cs | 35 ++++++++++++++++ .../Utility/OrbitCameraMouseControl.cs.meta | 2 + 4 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 Assets/_Scripts/Utility/OrbitCameraMouseControl.cs create mode 100644 Assets/_Scripts/Utility/OrbitCameraMouseControl.cs.meta diff --git a/Assets/MetaXR/MetaXRProjectSettings.asset b/Assets/MetaXR/MetaXRProjectSettings.asset index ea2ff4f..069800c 100644 --- a/Assets/MetaXR/MetaXRProjectSettings.asset +++ b/Assets/MetaXR/MetaXRProjectSettings.asset @@ -16,7 +16,8 @@ MonoBehaviour: keys: - Meta.XR.SDK.UsageSettings.UsesProjectSetupTool - Meta.XR.SDK.UsageSettings.UsesBuildingBlocks - values: 0101 + - Meta.XR.SDK.UsageSettings.UsesXRSimulator + values: 010101 intProperties: keys: [] values: diff --git a/Assets/_Scenes/TrainingObserverMeta.unity b/Assets/_Scenes/TrainingObserverMeta.unity index 30c6f58..0428cda 100644 --- a/Assets/_Scenes/TrainingObserverMeta.unity +++ b/Assets/_Scenes/TrainingObserverMeta.unity @@ -732,7 +732,7 @@ MonoBehaviour: m_StreamingVersion: 20241001 m_LegacyPriority: 0 Target: - TrackingTarget: {fileID: 6913818243333983922} + TrackingTarget: {fileID: 127221674} LookAtTarget: {fileID: 0} CustomLookAtTarget: 0 Lens: @@ -3070,7 +3070,7 @@ MonoBehaviour: m_StreamingVersion: 20241001 m_LegacyPriority: 0 Target: - TrackingTarget: {fileID: 6913818243333983922} + TrackingTarget: {fileID: 1163434184} LookAtTarget: {fileID: 0} CustomLookAtTarget: 0 Lens: @@ -3620,6 +3620,7 @@ GameObject: - component: {fileID: 737210445} - component: {fileID: 737210444} - component: {fileID: 737210443} + - component: {fileID: 737210448} m_Layer: 0 m_Name: OrbitCam m_TagString: Untagged @@ -3658,7 +3659,7 @@ MonoBehaviour: DecelTime: 0.2 - Name: Look Orbit Y Owner: {fileID: 737210445} - Enabled: 1 + Enabled: 0 Input: InputAction: {fileID: -5630151704836100654, guid: 1d6e640e716dc4ff6989b73d02023f2b, type: 3} @@ -3755,9 +3756,9 @@ MonoBehaviour: Time: 2 Restrictions: 0 VerticalAxis: - Value: 17.5 - Center: 17.5 - Range: {x: -10, y: 45} + Value: 30 + Center: 30 + Range: {x: -10, y: 60} Wrap: 0 Recentering: Enabled: 0 @@ -3765,9 +3766,9 @@ MonoBehaviour: Time: 2 Restrictions: 0 RadialAxis: - Value: 1 - Center: 1 - Range: {x: 1, y: 1} + Value: 0.1 + Center: 0.1 + Range: {x: 0.1, y: 1} Wrap: 0 Recentering: Enabled: 0 @@ -3794,7 +3795,7 @@ MonoBehaviour: m_StreamingVersion: 20241001 m_LegacyPriority: 0 Target: - TrackingTarget: {fileID: 6913818243333983922} + TrackingTarget: {fileID: 1163434184} LookAtTarget: {fileID: 0} CustomLookAtTarget: 0 Lens: @@ -3825,13 +3826,28 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 737210442} serializedVersion: 2 - m_LocalRotation: {x: 0.1521234, y: 0.0000000041576134, z: -6.3991795e-10, w: 0.98836154} - m_LocalPosition: {x: 0, y: 3.0070581, z: -9.537169} + m_LocalRotation: {x: 0.25881907, y: 5.2428895e-23, z: -1.3116896e-23, w: 0.9659259} + m_LocalPosition: {x: 0, y: 0.5, z: -0.8660254} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &737210448 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 737210442} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 77bfd51a51660c04b8c06ccb69c96587, type: 3} + m_Name: + m_EditorClassIdentifier: + aimAction: {fileID: -1608118824973676762, guid: 1d6e640e716dc4ff6989b73d02023f2b, + type: 3} + inputAxisController: {fileID: 737210443} --- !u!1 &742612850 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/_Scripts/Utility/OrbitCameraMouseControl.cs b/Assets/_Scripts/Utility/OrbitCameraMouseControl.cs new file mode 100644 index 0000000..b0456b4 --- /dev/null +++ b/Assets/_Scripts/Utility/OrbitCameraMouseControl.cs @@ -0,0 +1,35 @@ +using UnityEngine; +using UnityEngine.InputSystem; +using Unity.Cinemachine; + +public class OrbitCameraMouseControl : MonoBehaviour +{ + [Header("Input Actions")] + public InputActionReference aimAction; // CM Default / Aim + + [Header("Cinemachine Components")] + public CinemachineInputAxisController inputAxisController; + + private void OnEnable() + { + if (aimAction != null) + aimAction.action.Enable(); + } + + private void OnDisable() + { + if (aimAction != null) + aimAction.action.Disable(); + } + + void Update() + { + bool isAiming = aimAction != null && aimAction.action.ReadValue() > 0.5f; + + if (inputAxisController != null) + { + inputAxisController.Controllers[0].Enabled = isAiming; + inputAxisController.Controllers[1].Enabled = isAiming; + } + } +} diff --git a/Assets/_Scripts/Utility/OrbitCameraMouseControl.cs.meta b/Assets/_Scripts/Utility/OrbitCameraMouseControl.cs.meta new file mode 100644 index 0000000..4e4eec1 --- /dev/null +++ b/Assets/_Scripts/Utility/OrbitCameraMouseControl.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 77bfd51a51660c04b8c06ccb69c96587 \ No newline at end of file