Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teleportation Area does not find Teleportation Provider when in another scene [Fix Found] #72

Open
LeaT113 opened this issue Aug 5, 2021 · 1 comment

Comments

@LeaT113
Copy link

LeaT113 commented Aug 5, 2021

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.
@jackjansen
Copy link

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.

Not pretty but it does the job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants