You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scene 1 has the XR Rig and all the XR scripts including Teleportation Provider. Scene 2 has a Teleportation Area. Scene 2 is active.
When hitting play in Editor, the Teleportation Area correctly acquires an XR Interaction Manager reference (from Scene 1), but does not find the Teleportation Provider reference (that also resides in Scene 1). This results in a non-functional TP Area. When put into Scene 1, it does find a Teleportation Provider reference successfully.
Analysis
It seems this is caused by using the Awake method instead of the Start method. I created a script that uses FindObjectOfType<TeleportationProvider>(), same as the internal XRI logic, and it was unable to find the reference in the Awake method. However, when I put the same method call into the Start method, it found the reference.
As to why the XR Interaction Manager is found, but the Teleportation Provider isn't - I believe that is because when I traced how the Interaction Manager reference is acquired, I found it is in the XRBaseInteractable class, there is an #if UNITY_EDITOR that uses an EditorComponentLocatorUtility.FindSceneComponentOfType<T>(Scene scene) that seems to have the ability to find the reference in other scenes.
Possible fixes:
use the EditorComponentLocatorUtility for the Teleportation Provider reference too
use Start instead of Awake for sourcing the Teleportation Provider reference. I am not sure the first solution would work, as it would only affect the Editor and I'm unsure if this issue is present in Builds, I only tested the Editor behavior.
The text was updated successfully, but these errors were encountered:
I came across this issue in slightly different situation: because of the business logic requirements my whole XRRig and all that is created after the scene has started.
I added a script FixTeleportAreas to my XRRig prefab that uses FindObjectsOfType<BaseTeleportationInteractable>() to find all teleportation areas and anchors and fills in the correct interactionManager and teleportationProvider.
Scene 1 has the XR Rig and all the XR scripts including
Teleportation Provider
.Scene 2 has a
Teleportation Area
. Scene 2 is active.When hitting play in Editor, the
Teleportation Area
correctly acquires anXR Interaction Manager
reference (from Scene 1), but does not find theTeleportation Provider
reference (that also resides in Scene 1). This results in a non-functional TP Area. When put into Scene 1, it does find a Teleportation Provider reference successfully.Analysis
It seems this is caused by using the
Awake
method instead of theStart
method. I created a script that usesFindObjectOfType<TeleportationProvider>()
, same as the internal XRI logic, and it was unable to find the reference in the Awake method. However, when I put the same method call into the Start method, it found the reference.As to why the
XR Interaction Manager
is found, but theTeleportation Provider
isn't - I believe that is because when I traced how the Interaction Manager reference is acquired, I found it is in theXRBaseInteractable
class, there is an#if UNITY_EDITOR
that uses anEditorComponentLocatorUtility.FindSceneComponentOfType<T>(Scene scene)
that seems to have the ability to find the reference in other scenes.Possible fixes:
EditorComponentLocatorUtility
for the Teleportation Provider reference tooStart
instead ofAwake
for sourcing theTeleportation Provider
reference. I am not sure the first solution would work, as it would only affect the Editor and I'm unsure if this issue is present in Builds, I only tested the Editor behavior.The text was updated successfully, but these errors were encountered: