diff --git a/Assets/Oculus/VR/Scripts/Util/OVRMesh.cs b/Assets/Oculus/VR/Scripts/Util/OVRMesh.cs index 8c55c606..2ae83bd7 100644 --- a/Assets/Oculus/VR/Scripts/Util/OVRMesh.cs +++ b/Assets/Oculus/VR/Scripts/Util/OVRMesh.cs @@ -66,7 +66,10 @@ private void Awake() private void Initialize(MeshType meshType) { - _mesh = new Mesh(); + if (null == _mesh) + { + _mesh = new Mesh(); + } var ovrpMesh = new OVRPlugin.Mesh(); if (OVRPlugin.GetMesh((OVRPlugin.MeshType)_meshType, out ovrpMesh)) @@ -120,10 +123,9 @@ private void Initialize(MeshType meshType) } } -#if UNITY_EDITOR private void Update() { - if (OVRInput.IsControllerConnected(OVRInput.Controller.Hands) && !IsInitialized) + if (!IsInitialized && OVRInput.IsControllerConnected(OVRInput.Controller.Hands)) { if (_meshType != MeshType.None) { @@ -131,5 +133,4 @@ private void Update() } } } -#endif } diff --git a/Assets/Oculus/VR/Scripts/Util/OVRMeshRenderer.cs b/Assets/Oculus/VR/Scripts/Util/OVRMeshRenderer.cs index 21a122d8..7c8ad55d 100644 --- a/Assets/Oculus/VR/Scripts/Util/OVRMeshRenderer.cs +++ b/Assets/Oculus/VR/Scripts/Util/OVRMeshRenderer.cs @@ -171,14 +171,9 @@ private void Update() } } } -#if UNITY_EDITOR - else + else if (OVRInput.IsControllerConnected(OVRInput.Controller.Hands)) { - if (OVRInput.IsControllerConnected(OVRInput.Controller.Hands)) - { - Initialize(); - } + Initialize(); } -#endif } } diff --git a/Assets/Oculus/VR/Scripts/Util/OVRSkeleton.cs b/Assets/Oculus/VR/Scripts/Util/OVRSkeleton.cs index 78d10402..b392bb0d 100644 --- a/Assets/Oculus/VR/Scripts/Util/OVRSkeleton.cs +++ b/Assets/Oculus/VR/Scripts/Util/OVRSkeleton.cs @@ -292,15 +292,13 @@ private void InitializeCapsules(OVRPlugin.Skeleton skeleton) private void Update() { -#if UNITY_EDITOR - if (OVRInput.IsControllerConnected(OVRInput.Controller.Hands) && !IsInitialized) + if (!IsInitialized && OVRInput.IsControllerConnected(OVRInput.Controller.Hands)) { if (_skeletonType != SkeletonType.None) { Initialize(); } } -#endif if (!IsInitialized || _dataProvider == null) { diff --git a/Assets/Oculus/VR/Scripts/Util/OVRSkeletonRenderer.cs b/Assets/Oculus/VR/Scripts/Util/OVRSkeletonRenderer.cs index d3c32d88..0e5d82f2 100644 --- a/Assets/Oculus/VR/Scripts/Util/OVRSkeletonRenderer.cs +++ b/Assets/Oculus/VR/Scripts/Util/OVRSkeletonRenderer.cs @@ -236,11 +236,26 @@ private void Start() private void Initialize() { - _boneVisualizations = new List(); - _capsuleVisualizations = new List(); - _ovrSkeleton = GetComponent(); - _skeletonGO = new GameObject("SkeletonRenderer"); - _skeletonGO.transform.SetParent(transform, false); + if (null == _boneVisualizations) + { + _boneVisualizations = new List(); + } + + if (null == _capsuleVisualizations) + { + _capsuleVisualizations = new List(); + } + + if (null == _ovrSkeleton) + { + _ovrSkeleton = GetComponent(); + } + + if (null == _skeletonGO) + { + _skeletonGO = new GameObject("SkeletonRenderer"); + _skeletonGO.transform.SetParent(transform, false); + } if (_skeletonMaterial == null) { @@ -331,15 +346,10 @@ public void Update() _capsuleVisualizations[i].Update(_scale, shouldRender, ShouldUseSystemGestureMaterial, _confidenceBehavior, _systemGestureBehavior); } } -#if UNITY_EDITOR - else + else if (OVRInput.IsControllerConnected(OVRInput.Controller.Hands)) { - if (OVRInput.IsControllerConnected(OVRInput.Controller.Hands) && !IsInitialized) - { - Initialize(); - } + Initialize(); } -#endif } private void OnDestroy() diff --git a/Assets/Scenes/QuestAppLauncher.unity b/Assets/Scenes/QuestAppLauncher.unity index 72d03097..bf7697b8 100644 --- a/Assets/Scenes/QuestAppLauncher.unity +++ b/Assets/Scenes/QuestAppLauncher.unity @@ -8303,7 +8303,7 @@ PrefabInstance: - target: {fileID: 114392993255165844, guid: 835e735ca71bf78459fb2cababd74112, type: 3} propertyPath: m_Enabled - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 114392993255165844, guid: 835e735ca71bf78459fb2cababd74112, type: 3} @@ -9912,7 +9912,7 @@ PrefabInstance: - target: {fileID: 114392993255165844, guid: 835e735ca71bf78459fb2cababd74112, type: 3} propertyPath: m_Enabled - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 114392993255165844, guid: 835e735ca71bf78459fb2cababd74112, type: 3}