Skip to content

Commit

Permalink
fix(SharedMethods): change FindEvenInactive to search all loaded scenes
Browse files Browse the repository at this point in the history
Search all loaded scenes instead of just the active scene
  • Loading branch information
kristianpd committed Feb 13, 2018
1 parent 6cb3086 commit 0918143
Show file tree
Hide file tree
Showing 22 changed files with 88 additions and 67 deletions.
2 changes: 1 addition & 1 deletion Assets/VRTK/Source/Editor/VRTK_SDKManagerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public override void OnInspectorGUI()
SerializedProperty serializedProperty = setupsList.serializedProperty;
serializedProperty.ClearArray();
VRTK_SDKSetup[] setups = sdkManager.GetComponentsInChildren<VRTK_SDKSetup>(true)
.Concat(VRTK_SharedMethods.FindEvenInactiveComponents<VRTK_SDKSetup>())
.Concat(VRTK_SharedMethods.FindEvenInactiveComponents<VRTK_SDKSetup>(true))
.Distinct()
.ToArray();

Expand Down
2 changes: 1 addition & 1 deletion Assets/VRTK/Source/SDK/Daydream/SDK_DaydreamController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public override GameObject GetControllerRightHand(bool actual = false)
controller = GetSDKManagerControllerRightHand(actual);
if ((controller == null) && actual)
{
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<GvrControllerVisualManager>("Controller");
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<GvrControllerVisualManager>("Controller", true);
}
if (controller != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override Transform GetPlayArea()
cachedPlayArea = GetSDKManagerPlayArea();
if (cachedPlayArea == null)
{
GameObject myHeadGO = VRTK_SharedMethods.FindEvenInactiveGameObject<HyHead>();
GameObject myHeadGO = VRTK_SharedMethods.FindEvenInactiveGameObject<HyHead>(null, true);
cachedPlayArea = (myHeadGO != null ? myHeadGO.transform.parent : null);
}
return cachedPlayArea;
Expand Down
4 changes: 2 additions & 2 deletions Assets/VRTK/Source/SDK/HyperealVR/SDK_HyperealVRController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public override GameObject GetControllerLeftHand(bool actual = false)
{
if (actual)
{
HyTrackObjRig trackedObjRig = VRTK_SharedMethods.FindEvenInactiveComponent<HyTrackObjRig>();
HyTrackObjRig trackedObjRig = VRTK_SharedMethods.FindEvenInactiveComponent<HyTrackObjRig>(true);
if (trackedObjRig)
{
return trackedObjRig.leftController;
Expand All @@ -174,7 +174,7 @@ public override GameObject GetControllerRightHand(bool actual = false)
{
if (actual)
{
HyTrackObjRig trackedObjRig = VRTK_SharedMethods.FindEvenInactiveComponent<HyTrackObjRig>();
HyTrackObjRig trackedObjRig = VRTK_SharedMethods.FindEvenInactiveComponent<HyTrackObjRig>(true);
if (trackedObjRig)
{
return trackedObjRig.rightController;
Expand Down
4 changes: 2 additions & 2 deletions Assets/VRTK/Source/SDK/HyperealVR/SDK_HyperealVRHeadset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override Transform GetHeadset()
cachedHeadset = GetSDKManagerHeadset();
if (cachedHeadset == null)
{
GameObject myHeadGO = VRTK_SharedMethods.FindEvenInactiveGameObject<HyHead>();
GameObject myHeadGO = VRTK_SharedMethods.FindEvenInactiveGameObject<HyHead>(null, true);
cachedHeadset = (myHeadGO != null ? myHeadGO.transform : null);
}
return cachedHeadset;
Expand All @@ -56,7 +56,7 @@ public override Transform GetHeadset()
/// <returns>A transform of the object holding the headset camera in the scene.</returns>
public override Transform GetHeadsetCamera()
{
GameObject myHeadsetCameraGO = VRTK_SharedMethods.FindEvenInactiveGameObject<HyCamera>();
GameObject myHeadsetCameraGO = VRTK_SharedMethods.FindEvenInactiveGameObject<HyCamera>(null, true);
cachedHeadsetCamera = (myHeadsetCameraGO != null ? myHeadsetCameraGO.transform : null);
return cachedHeadsetCamera;
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/VRTK/Source/SDK/Oculus/SDK_OculusBoundaries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override Transform GetPlayArea()
cachedPlayArea = GetSDKManagerPlayArea();
if (cachedPlayArea == null)
{
OVRManager ovrManager = VRTK_SharedMethods.FindEvenInactiveComponent<OVRManager>();
OVRManager ovrManager = VRTK_SharedMethods.FindEvenInactiveComponent<OVRManager>(true);
if (ovrManager != null)
{
cachedPlayArea = ovrManager.transform;
Expand Down Expand Up @@ -122,7 +122,7 @@ public virtual OvrAvatar GetAvatar()
{
if (avatarContainer == null)
{
avatarContainer = VRTK_SharedMethods.FindEvenInactiveComponent<OvrAvatar>();
avatarContainer = VRTK_SharedMethods.FindEvenInactiveComponent<OvrAvatar>(true);
if (avatarContainer != null && avatarContainer.GetComponent<VRTK_TransformFollow>() == null)
{
VRTK_TransformFollow objectFollow = avatarContainer.gameObject.AddComponent<VRTK_TransformFollow>();
Expand Down
4 changes: 2 additions & 2 deletions Assets/VRTK/Source/SDK/Oculus/SDK_OculusController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public override GameObject GetControllerLeftHand(bool actual = false)
GameObject controller = GetSDKManagerControllerLeftHand(actual);
if (controller == null && actual)
{
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<OVRCameraRig>("TrackingSpace/LeftHandAnchor");
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<OVRCameraRig>("TrackingSpace/LeftHandAnchor", true);
}
return controller;
}
Expand All @@ -249,7 +249,7 @@ public override GameObject GetControllerRightHand(bool actual = false)
GameObject controller = GetSDKManagerControllerRightHand(actual);
if (controller == null && actual)
{
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<OVRCameraRig>("TrackingSpace/RightHandAnchor");
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<OVRCameraRig>("TrackingSpace/RightHandAnchor", true);
}
return controller;
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/VRTK/Source/SDK/Oculus/SDK_OculusHeadset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public override Transform GetHeadset()
cachedHeadset = GetSDKManagerHeadset();
if (cachedHeadset == null)
{
cachedHeadset = VRTK_SharedMethods.FindEvenInactiveGameObject<OVRCameraRig>("TrackingSpace/CenterEyeAnchor").transform;
cachedHeadset = VRTK_SharedMethods.FindEvenInactiveGameObject<OVRCameraRig>("TrackingSpace/CenterEyeAnchor", true).transform;
}
return cachedHeadset;
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/VRTK/Source/SDK/Simulator/SDK_InputSimulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public static GameObject FindInScene()
{
if (cachedCameraRig == null && !destroyed)
{
cachedCameraRig = VRTK_SharedMethods.FindEvenInactiveGameObject<SDK_InputSimulator>();
cachedCameraRig = VRTK_SharedMethods.FindEvenInactiveGameObject<SDK_InputSimulator>(null, true);
if (!cachedCameraRig)
{
VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_SCENE, "[VRSimulator_CameraRig]", "SDK_InputSimulator", ". check that the `VRTK/Prefabs/CameraRigs/[VRSimulator_CameraRig]` prefab been added to the scene."));
Expand Down
2 changes: 1 addition & 1 deletion Assets/VRTK/Source/SDK/SteamVR/SDK_SteamVRBoundaries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public override Transform GetPlayArea()
cachedPlayArea = GetSDKManagerPlayArea();
if (cachedPlayArea == null)
{
SteamVR_PlayArea steamVRPlayArea = VRTK_SharedMethods.FindEvenInactiveComponent<SteamVR_PlayArea>();
SteamVR_PlayArea steamVRPlayArea = VRTK_SharedMethods.FindEvenInactiveComponent<SteamVR_PlayArea>(true);
if (steamVRPlayArea != null)
{
cachedSteamVRPlayArea = steamVRPlayArea;
Expand Down
4 changes: 2 additions & 2 deletions Assets/VRTK/Source/SDK/SteamVR/SDK_SteamVRController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public override GameObject GetControllerLeftHand(bool actual = false)
GameObject controller = GetSDKManagerControllerLeftHand(actual);
if (controller == null && actual)
{
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<SteamVR_ControllerManager>("Controller (left)");
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<SteamVR_ControllerManager>("Controller (left)", true);
}
return controller;
}
Expand All @@ -278,7 +278,7 @@ public override GameObject GetControllerRightHand(bool actual = false)
GameObject controller = GetSDKManagerControllerRightHand(actual);
if (controller == null && actual)
{
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<SteamVR_ControllerManager>("Controller (right)");
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<SteamVR_ControllerManager>("Controller (right)", true);
}
return controller;
}
Expand Down
6 changes: 3 additions & 3 deletions Assets/VRTK/Source/SDK/SteamVR/SDK_SteamVRHeadset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public override Transform GetHeadset()
if (cachedHeadset == null)
{
#if (UNITY_5_4_OR_NEWER)
SteamVR_Camera foundCamera = VRTK_SharedMethods.FindEvenInactiveComponent<SteamVR_Camera>();
SteamVR_Camera foundCamera = VRTK_SharedMethods.FindEvenInactiveComponent<SteamVR_Camera>(true);
#else
SteamVR_GameView foundCamera = VRTK_SharedMethods.FindEvenInactiveComponent<SteamVR_GameView>();
SteamVR_GameView foundCamera = VRTK_SharedMethods.FindEvenInactiveComponent<SteamVR_GameView>(true);
#endif
if (foundCamera != null)
{
Expand All @@ -66,7 +66,7 @@ public override Transform GetHeadsetCamera()
cachedHeadsetCamera = GetSDKManagerHeadset();
if (cachedHeadsetCamera == null)
{
SteamVR_Camera foundCamera = VRTK_SharedMethods.FindEvenInactiveComponent<SteamVR_Camera>();
SteamVR_Camera foundCamera = VRTK_SharedMethods.FindEvenInactiveComponent<SteamVR_Camera>(true);
if (foundCamera != null)
{
cachedHeadsetCamera = foundCamera.transform;
Expand Down
2 changes: 1 addition & 1 deletion Assets/VRTK/Source/SDK/Unity/SDK_UnityBoundaries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override Transform GetPlayArea()
cachedPlayArea = GetSDKManagerPlayArea();
if (cachedPlayArea == null)
{
GameObject foundCameraRig = VRTK_SharedMethods.FindEvenInactiveGameObject<SDK_UnityCameraRig>();
GameObject foundCameraRig = VRTK_SharedMethods.FindEvenInactiveGameObject<SDK_UnityCameraRig>(null, true);
if (foundCameraRig != null)
{
cachedPlayArea = foundCameraRig.transform;
Expand Down
4 changes: 2 additions & 2 deletions Assets/VRTK/Source/SDK/Unity/SDK_UnityController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public override GameObject GetControllerLeftHand(bool actual = false)
GameObject controller = GetSDKManagerControllerLeftHand(actual);
if (controller == null && actual)
{
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<SDK_UnityCameraRig>("LeftHandAnchor");
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<SDK_UnityCameraRig>("LeftHandAnchor", true);
}
return controller;
}
Expand All @@ -262,7 +262,7 @@ public override GameObject GetControllerRightHand(bool actual = false)
GameObject controller = GetSDKManagerControllerRightHand(actual);
if (controller == null && actual)
{
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<SDK_UnityCameraRig>("RightHandAnchor");
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<SDK_UnityCameraRig>("RightHandAnchor", true);
}
return controller;
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/VRTK/Source/SDK/Unity/SDK_UnityHeadset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public override Transform GetHeadset()
cachedHeadset = GetSDKManagerHeadset();
if (cachedHeadset == null)
{
GameObject foundHeadset = VRTK_SharedMethods.FindEvenInactiveGameObject<SDK_UnityHeadsetTracker>();
GameObject foundHeadset = VRTK_SharedMethods.FindEvenInactiveGameObject<SDK_UnityHeadsetTracker>(null, true);
if (foundHeadset != null)
{
cachedHeadset = foundHeadset.transform;
Expand Down
2 changes: 1 addition & 1 deletion Assets/VRTK/Source/SDK/Ximmerse/SDK_XimmerseBoundaries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override Transform GetPlayArea()
cachedPlayArea = GetSDKManagerPlayArea();
if (cachedPlayArea == null)
{
VRContext vrContext = VRTK_SharedMethods.FindEvenInactiveComponent<VRContext>();
VRContext vrContext = VRTK_SharedMethods.FindEvenInactiveComponent<VRContext>(true);
if (Application.isPlaying)
{
vrContext.InitVRContext();
Expand Down
4 changes: 2 additions & 2 deletions Assets/VRTK/Source/SDK/Ximmerse/SDK_XimmerseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public override GameObject GetControllerLeftHand(bool actual = false)
GameObject controller = GetSDKManagerControllerLeftHand(actual);
if (controller == null && actual)
{
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<VRContext>("TrackingSpace/LeftHandAnchor");
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<VRContext>("TrackingSpace/LeftHandAnchor", true);
}
return controller;
}
Expand All @@ -228,7 +228,7 @@ public override GameObject GetControllerRightHand(bool actual = false)
GameObject controller = GetSDKManagerControllerRightHand(actual);
if (controller == null && actual)
{
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<VRContext>("TrackingSpace/RightHandAnchor");
controller = VRTK_SharedMethods.FindEvenInactiveGameObject<VRContext>("TrackingSpace/RightHandAnchor", true);
}
return controller;
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/VRTK/Source/SDK/Ximmerse/SDK_XimmerseHeadset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public override Transform GetHeadset()
cachedHeadset = GetSDKManagerHeadset();
if (cachedHeadset == null)
{
var foundHeadset = VRTK_SharedMethods.FindEvenInactiveGameObject<VRContext>("TrackingSpace/CenterEyeAnchor");
var foundHeadset = VRTK_SharedMethods.FindEvenInactiveGameObject<VRContext>("TrackingSpace/CenterEyeAnchor", true);
if (foundHeadset)
{
cachedHeadset = foundHeadset.transform;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected virtual void OnEnable()
break;
}
}
internalBodyPhysics = (internalBodyPhysics == null ? VRTK_SharedMethods.FindEvenInactiveComponent<VRTK_BodyPhysics>() : internalBodyPhysics);
internalBodyPhysics = (internalBodyPhysics == null ? VRTK_SharedMethods.FindEvenInactiveComponent<VRTK_BodyPhysics>(true) : internalBodyPhysics);
}

protected virtual void OnDisable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public static VRTK_SDKManager instance
{
if (_instance == null)
{
VRTK_SDKManager sdkManager = VRTK_SharedMethods.FindEvenInactiveComponent<VRTK_SDKManager>();
VRTK_SDKManager sdkManager = VRTK_SharedMethods.FindEvenInactiveComponent<VRTK_SDKManager>(true);
if (sdkManager != null)
{
sdkManager.CreateInstance();
Expand Down
2 changes: 1 addition & 1 deletion Assets/VRTK/Source/Scripts/Utilities/SDK/VRTK_SDKSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ private static void AutoPopulateObjectReferences()
return;
}

foreach (VRTK_SDKSetup setup in VRTK_SharedMethods.FindEvenInactiveComponents<VRTK_SDKSetup>())
foreach (VRTK_SDKSetup setup in VRTK_SharedMethods.FindEvenInactiveComponents<VRTK_SDKSetup>(true))
{
setup.PopulateObjectReferences(false);
}
Expand Down
Loading

0 comments on commit 0918143

Please sign in to comment.