Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question XR Rig persistence across multiple scenes

Discussion in 'VR' started by MarkSharpe, Nov 26, 2021.

  1. MarkSharpe

    MarkSharpe

    Joined:
    Feb 3, 2021
    Posts:
    27
    I currently have two scenes I am attempting to use the same XR rig prefab on. I while I am able to load the scene and the HMD camera persists. With which I am able to look around into the new scene. However, the XR controllers and their inputs are not coming over. I brought the event system over and the XR rig and inputs are working. However, upon returning to the main scene the XR rig is immobile and not at the origin which I would like to be able to set.

    Here are the events tied to the UIinterface I'm using

    public void ReturnToMenu()
    {
    SceneManager.LoadScene(0);
    Debug.Log("MainMenu Button");
    }
    public void Tutorial()
    {
    SceneManager.LoadScene(1);
    }
     
    Last edited: Nov 26, 2021
  2. joey23212

    joey23212

    Joined:
    Jan 10, 2022
    Posts:
    1
    Add all xr rig related components into a parent and add this script:


    void Start()
    {
    if (instance == null)
    {
    instance = this;
    DontDestroyOnLoad(this);
    }
    else
    {
    Destroy(gameObject);
    }
    }
     
    MarkSharpe likes this.
  3. MarkSharpe

    MarkSharpe

    Joined:
    Feb 3, 2021
    Posts:
    27
    Works perfectly. Thanks!