#Ending a WebXR Session

1 messages Β· Page 1 of 1 (latest)

proper inlet
#

Hi all πŸ‘‹ πŸ˜€

I've been meaning to ask this question for a little while but keep forgetting to do so πŸ˜Άβ€πŸŒ«οΈ πŸ˜…

Basically, I have Needle's 'Open URL' script set up to take users to a web page in a new tab when clicked - and I also have a button component assigned to the same game object to ensure that a VR session (if a user is in it) is stopped at the same time.

I used to be able to assign 'WebXR.endSession' on click, but that option doesn't seem to be available anymore.

Could someone advise which of the following (see screenshot) I should choose to achieve the same result as WebXR.endSession?

Cheeeeeeeeeeeeers in advance πŸ™‚

visual roseBOT
# proper inlet Hi all πŸ‘‹ πŸ˜€ I've been meaning to ask this question for a little while but kee...

Thanks for reaching out @proper inlet

Please read through the following and share the information requested. This will help us to better assist you.

Description

Describe the issue that you're seeing. Please be as detailed as possible e.g. is this issue happening in Unity or Blender, which Needle Engine version are you using, do you see any errors in the Editor or Browser console, etc.

Information:

  • If you're using Unity click the menu item Needle Engine/Report a Bug/Copy Project Info to Clipboard. Please share the results below.
  • Please provide code snippets using Discord Code Blocks
  • Have you contacted Needle through another channel or just through Discord?

Thanks for submitting!

πŸ’‘ Did you know that we now also have a forum with AI support? Join now with your discord account!

How it works:
Reply to the messages of the bot that end with a thread_id to interact with it and ask follow-up questions. You can also mention the bot directly in this channel to get help.

Help requested: please wait a moment...

visual roseBOT
# proper inlet Hi all πŸ‘‹ πŸ˜€ I've been meaning to ask this question for a little while but kee...

Hello Frannie! 😊

To achieve the same result as WebXR.endSession for stopping a VR session and then opening a URL, you should directly use the endSession() method provided by the WebXR component in Needle Engine.

In the context of the Needle Engine scripting API, endSession() is a method of the WebXR class that will end the current WebXR session. This function is exactly what you're looking for to gracefully exit the VR session before navigating to a new page.

After calling endSession(), you can proceed with the logic to open the desired URL in a new browser tab, as you've set up previously with the 'Open URL' script and button component.

I hope this helps answer your question! Let me know if you need further assistance. Cheers! 🍻 (see the documentation).

0 messages left
thread_2uqfiPmCPSTyVz8UmrbvZmQa

dusty sundial
#

Ah, thanks for noticing :)
The function is still there, but is not exposed correctly in Unity.

In the meantime you can call the api directly:

NeedleXRSession.stop();

Will try to propose it for the next engine release :) more up to marcel.

proper inlet
#

Hi @dusty sundial and many thanks for the response, it's greatly appreciated πŸ™‚

Could you let me know where/how I should add what you've suggested?

T.I.A. πŸ™‚

dusty sundial
#
import { Behaviour, NeedleXRSession } from "@needle-tools/engine";

export class WebXRHelper extends Behaviour {
    exitXR() {
        NeedleXRSession.stop();
    }
}

Create a script like this one, place it on a game object, and in the button select this component and call exitXR