VeriorPies / ParrelSync

(Unity3D) Test multiplayer without building
MIT License
4.67k stars 323 forks source link

Using ParrelSync on OpenXR with SteamVR #77

Open Maciej92Zareba opened 2 years ago

Maciej92Zareba commented 2 years ago

Hi I though I'm gona share solution on using ParrelSync when using SteamVR. SteamVR allows only 1 active connection to it so in order to use it With ParrelSync you need to disable VR on one of your mashine and enable it on other. Here is script I'm using for it. (Unity 2021.2.19)

using Sirenix.OdinInspector;
using System.Collections;
using UnityEngine.XR.Management;

public class VRUtilities : ExtendedMonoBehaviour
{
    [Button]
    public void EnableXR ()
    {
        StartCoroutine(StartXRCoroutine());
    }

    [Button]
    public void DisableXR ()
    {
        Logger.Log("Stopping XR...");
        XRGeneralSettings.Instance.Manager.StopSubsystems();
        XRGeneralSettings.Instance.Manager.DeinitializeLoader();
        Logger.Log("XR stopped completely.");
    }

    public IEnumerator StartXRCoroutine ()
    {
        Logger.Log("Initializing XR...");
        yield return XRGeneralSettings.Instance.Manager.InitializeLoader();

        if (XRGeneralSettings.Instance.Manager.activeLoader == null)
        {
            Logger.LogError("Initializing XR Failed. Check Editor or Player log for details.");
        }
        else
        {
            Logger.Log("Starting XR...");
            XRGeneralSettings.Instance.Manager.StartSubsystems();
        }
    }
}
imbeyondboredom commented 2 years ago

Important note here - In order for this to work you also need to disable VR on startup: [Edit]->[Project Settings] -> [XR Plug-in Management] -> Select the desktop tab -> Uncheck "Initialize XR on Startup"

For me it's still a bit finnicky where sometimes steamvr doesn't close out the old game but it does work!

InkedUnity_ZYoVn3fxRO

Maciej92Zareba commented 2 years ago

Ye, I forgot to add it here. Thanks