From 2981df153ea7ea7a46462c3a18c2b2ec2bd43ef8 Mon Sep 17 00:00:00 2001 From: Priyanshu Bhattacharjee Date: Sat, 28 Oct 2023 09:52:00 +0530 Subject: [PATCH] Rig Persistance for Scene Switching --- .../Components/OVRTK Camera Rig.prefab | 15 +++++++++++++ Assets/OVRTK/Scenes/360 Video/360Demo.unity | 4 ++++ Assets/OVRTK/Scenes/OVRTK_SampleScene.unity | 8 +++++++ Assets/OVRTK/Scripts/Core/GyroscopeManager.cs | 11 +++++----- .../Scripts/Core/GyroscopeStateManager.cs | 17 +++++++------- Assets/OVRTK/Scripts/Core/RigPersistance.cs | 22 +++++++++++++++++++ .../OVRTK/Scripts/Core/RigPersistance.cs.meta | 11 ++++++++++ .../OVRTK/Scripts/Core/SimulationManager.cs | 12 +++++----- .../OVRTK/Scripts/Core/StereoscopeManager.cs | 15 ++++++------- ProjectSettings/EditorBuildSettings.asset | 3 +++ 10 files changed, 89 insertions(+), 29 deletions(-) create mode 100644 Assets/OVRTK/Scripts/Core/RigPersistance.cs create mode 100644 Assets/OVRTK/Scripts/Core/RigPersistance.cs.meta diff --git a/Assets/OVRTK/Prefabs/Components/OVRTK Camera Rig.prefab b/Assets/OVRTK/Prefabs/Components/OVRTK Camera Rig.prefab index 92d8a87..d06e6ee 100644 --- a/Assets/OVRTK/Prefabs/Components/OVRTK Camera Rig.prefab +++ b/Assets/OVRTK/Prefabs/Components/OVRTK Camera Rig.prefab @@ -12,6 +12,7 @@ GameObject: - component: {fileID: 1397934825224362951} - component: {fileID: 5666297426116378531} - component: {fileID: 3649031560700094365} + - component: {fileID: 3223435628727167195} - component: {fileID: 761392224187919499} m_Layer: 0 m_Name: OVRTK Camera Rig @@ -87,6 +88,20 @@ MonoBehaviour: horizontalSpeed: 2 verticalSpeed: 2 EnableSimulator: 0 +--- !u!114 &3223435628727167195 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 761392224187919501} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 02ed6da50297342aaa1de23e4d398695, type: 3} + m_Name: + m_EditorClassIdentifier: + OVRTK_Rig: {fileID: 761392224187919501} + EnablePersistance: 0 --- !u!81 &761392224187919499 AudioListener: m_ObjectHideFlags: 0 diff --git a/Assets/OVRTK/Scenes/360 Video/360Demo.unity b/Assets/OVRTK/Scenes/360 Video/360Demo.unity index 23aa0dd..ce261b1 100644 --- a/Assets/OVRTK/Scenes/360 Video/360Demo.unity +++ b/Assets/OVRTK/Scenes/360 Video/360Demo.unity @@ -245,6 +245,10 @@ PrefabInstance: propertyPath: m_Name value: OVRTK Camera Rig objectReference: {fileID: 0} + - target: {fileID: 761392224187919501, guid: 054b12e31717fcc47a375fcc438085d7, type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} - target: {fileID: 5666297426116378531, guid: 054b12e31717fcc47a375fcc438085d7, type: 3} propertyPath: logUtils value: diff --git a/Assets/OVRTK/Scenes/OVRTK_SampleScene.unity b/Assets/OVRTK/Scenes/OVRTK_SampleScene.unity index 76dc371..ef346ce 100644 --- a/Assets/OVRTK/Scenes/OVRTK_SampleScene.unity +++ b/Assets/OVRTK/Scenes/OVRTK_SampleScene.unity @@ -178,10 +178,18 @@ PrefabInstance: propertyPath: m_Name value: OVRTK Camera Rig objectReference: {fileID: 0} + - target: {fileID: 3223435628727167195, guid: 054b12e31717fcc47a375fcc438085d7, type: 3} + propertyPath: EnablePersistance + value: 0 + objectReference: {fileID: 0} - target: {fileID: 3649031560700094365, guid: 054b12e31717fcc47a375fcc438085d7, type: 3} propertyPath: EnableSimulator value: 1 objectReference: {fileID: 0} + - target: {fileID: 5562324977107085019, guid: 054b12e31717fcc47a375fcc438085d7, type: 3} + propertyPath: m_Enabled + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 054b12e31717fcc47a375fcc438085d7, type: 3} --- !u!1 &804576818 diff --git a/Assets/OVRTK/Scripts/Core/GyroscopeManager.cs b/Assets/OVRTK/Scripts/Core/GyroscopeManager.cs index f97f900..644a41a 100644 --- a/Assets/OVRTK/Scripts/Core/GyroscopeManager.cs +++ b/Assets/OVRTK/Scripts/Core/GyroscopeManager.cs @@ -1,13 +1,12 @@ using System.Collections; using System.Collections.Generic; -using UnityEngine; - +using UnityEngine; + +/// +/// This script is responsible for managing the gyroscope functionality of a device and updating the rotation of a GameObject accordingly. +/// public class GyroscopeManager : MonoBehaviour { - /// - /// This script is responsible for managing the gyroscope functionality of a device and updating the rotation of a GameObject accordingly. - /// - private GyroscopeStateManager gyroscopeStateManager; public GyroscopeStateManager GyroscopeStateManager { diff --git a/Assets/OVRTK/Scripts/Core/GyroscopeStateManager.cs b/Assets/OVRTK/Scripts/Core/GyroscopeStateManager.cs index ecdfd03..cb05bfa 100644 --- a/Assets/OVRTK/Scripts/Core/GyroscopeStateManager.cs +++ b/Assets/OVRTK/Scripts/Core/GyroscopeStateManager.cs @@ -1,16 +1,15 @@ using System.Collections; using System.Collections.Generic; -using UnityEngine; - +using UnityEngine; + +/// +/// The code is for managing gyroscope support in Unity. +/// It checks whether the device supports a gyroscope, and if it doesn't, it enables a warning popup. +/// The script also has a reference to a SimulationManager component and a GyroscopeManager array, as well as a Quaternion variable for storing rotation data. +/// The SimulationManager component is set in the Start() method, and the enableGyroNotSupportedWarning() method is called to show the popup if necessary. +/// public class GyroscopeStateManager : MonoBehaviour { - /// - /// The code is for managing gyroscope support in Unity. - /// It checks whether the device supports a gyroscope, and if it doesn't, it enables a warning popup. - /// The script also has a reference to a SimulationManager component and a GyroscopeManager array, as well as a Quaternion variable for storing rotation data. - /// The SimulationManager component is set in the Start() method, and the enableGyroNotSupportedWarning() method is called to show the popup if necessary. - /// - private bool isGyroSupported; public GyroscopeManager[] gyroscopeManager; public GameObject _GyroNotSupportedPopUp; diff --git a/Assets/OVRTK/Scripts/Core/RigPersistance.cs b/Assets/OVRTK/Scripts/Core/RigPersistance.cs new file mode 100644 index 0000000..c76030d --- /dev/null +++ b/Assets/OVRTK/Scripts/Core/RigPersistance.cs @@ -0,0 +1,22 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +/// +/// The Persistence Rig is designed to enable smooth transitions between scenes without the need to reinitialize the OVRTK from scratch. +/// +public class RigPersistance : MonoBehaviour +{ + [SerializeField] + private GameObject OVRTK_Rig; + + public bool EnablePersistance = false; + + private void Start() + { + if (EnablePersistance) + { + DontDestroyOnLoad(OVRTK_Rig); + } + } +} \ No newline at end of file diff --git a/Assets/OVRTK/Scripts/Core/RigPersistance.cs.meta b/Assets/OVRTK/Scripts/Core/RigPersistance.cs.meta new file mode 100644 index 0000000..1d49917 --- /dev/null +++ b/Assets/OVRTK/Scripts/Core/RigPersistance.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 02ed6da50297342aaa1de23e4d398695 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/OVRTK/Scripts/Core/SimulationManager.cs b/Assets/OVRTK/Scripts/Core/SimulationManager.cs index a985f3a..829e69b 100644 --- a/Assets/OVRTK/Scripts/Core/SimulationManager.cs +++ b/Assets/OVRTK/Scripts/Core/SimulationManager.cs @@ -1,13 +1,13 @@ using System.Collections; using System.Collections.Generic; -using UnityEngine; - +using UnityEngine; + +/// +/// The above code defines a simulation manager that simulates a 3D experience using the mouse as input. +/// It has three public properties for adjusting the horizontal and vertical speed of the mouse movement and a boolean flag for enabling the simulator. +/// public class SimulationManager : MonoBehaviour { - /// - /// The above code defines a simulation manager that simulates a 3D experience using the mouse as input. - /// It has three public properties for adjusting the horizontal and vertical speed of the mouse movement and a boolean flag for enabling the simulator. - /// public float horizontalSpeed = 2f; public float verticalSpeed = 2f; public bool EnableSimulator; diff --git a/Assets/OVRTK/Scripts/Core/StereoscopeManager.cs b/Assets/OVRTK/Scripts/Core/StereoscopeManager.cs index 25a117d..3f4bca9 100644 --- a/Assets/OVRTK/Scripts/Core/StereoscopeManager.cs +++ b/Assets/OVRTK/Scripts/Core/StereoscopeManager.cs @@ -1,15 +1,14 @@ using System.Collections; using System.Collections.Generic; -using UnityEngine; - +using UnityEngine; + +/// +/// This script is used to create a stereoscopic effect for a virtual reality experience. +/// It sets up two cameras in the scene, one for the left eye and one for the right eye, and positions them to match the distance between the user's eyes, known as the interpupillary distance. +/// It also includes variables for eye height and eye depth, which can be adjusted to match the user's physical characteristics. +/// public class StereoscopeManager : MonoBehaviour { - /// - /// This script is used to create a stereoscopic effect for a virtual reality experience. - /// It sets up two cameras in the scene, one for the left eye and one for the right eye, and positions them to match the distance between the user's eyes, known as the interpupillary distance. - /// It also includes variables for eye height and eye depth, which can be adjusted to match the user's physical characteristics. - /// - [SerializeField] private Camera leftCamera; diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 5505393..9a30015 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -8,6 +8,9 @@ EditorBuildSettings: - enabled: 1 path: Assets/OVRTK/Scenes/360 Video/360Demo.unity guid: b0b83dbbd4866204aaa38e66dcfeac87 + - enabled: 1 + path: Assets/OVRTK/Scenes/OVRTK_SampleScene.unity + guid: 4c9b652dc705a374086c1bad6b8545ea m_configObjects: UnityEditor.XR.ARCore.ARCoreSettings: {fileID: 11400000, guid: 2e0e21c36b1f344448b879b9110e9989, type: 2} com.unity.xr.management.loader_settings: {fileID: 11400000, guid: 41bca3df2477f0a43b0a371d5991aa79, type: 2}