ValveSoftware / steamvr_unity_plugin

SteamVR Unity Plugin - Documentation at: https://valvesoftware.github.io/steamvr_unity_plugin/
BSD 3-Clause "New" or "Revised" License
1.03k stars 256 forks source link

Cannot disable AutoEnableVR #961

Open Mouledoux opened 3 years ago

Mouledoux commented 3 years ago

Unity 2020.3.5 OpenVR XR Plugin 1.0.1

SteamVR launches regardless of SteamVR_Setting.autoEnableVR being true or false UnityEngine.XR.XRSetting.enabled is also false at build time for all build devices.

Every single camera (except the disabled VR Player's camera) has TargetEye set to none.

XR.Enabled and autoEnableVR do get reset at runtime based on user settings, but they are both false by default, and SteamVR launches before the scene with that script even loads.

Mouledoux commented 3 years ago

Update: I did not know unity 2020 changed how you activate VR from XrSettings.enabled, to XRGeneralSettings.Instance.Manager.StartSubsystem / StopSubsystem https://docs.unity3d.com/Packages/com.unity.xr.management@4.0/api/UnityEngine.XR.Management.html

However, this still does not stop SteamVR from auto launching before that code is even called. SteamVR_Settings.autoEnableVR is still false, as is XR Plug-in Management's Initialize XR on startup for all devices

max-fluff commented 3 years ago

Same problem here. I've disabled auto-enabling toggles in XR plug-in manager settings and SteamVR_Resources/Resources/SteamVR_Settings but SteamVR still runs on app start.

Screenshots ![image](https://user-images.githubusercontent.com/48261468/121681309-50534500-cac3-11eb-8e79-434db22527be.png) ![image](https://user-images.githubusercontent.com/48261468/121681394-711b9a80-cac3-11eb-8f42-21f0aa2fd566.png)

Unity ver. 2020.3.8.f1 XR plug-in management package ver. 4.0.6 SteamVR package ver. 2.7.3

Mouledoux commented 3 years ago

I may have found part of the problem in the Player log Player.log

You can see it initializes the subsystems, and then calls XRGeneralSettings.Awake first before anything else.

AFTER that, then you can see where I tried to stop it from happening with "SE_InitializeUnityScene:InitializeVR(SequencedEvent)" code here:

private void InitializeVR(SequencedEvent a_event)
{
    bool _vrEnabled = MasterConfig.Instance.UnityDisplaySettings.useVR;
    XRManagerSettings _xrSettingsMgr = XRGeneralSettings.Instance.Manager;

    if(_vrEnabled)
    {
        _xrSettingsMgr.InitializeLoader();
        _xrSettingsMgr.StartSubsystems();
        XRSettings.gameViewRenderMode = GameViewRenderMode.RightEye;

        a_event.ProgressTextAddNewLine(($"VR Moduel Detected").AddRichTextTag("color", "yellow"));
        a_event.ProgressTextAddNewLine(($"\t VR Status: [ENABLED]").AddRichTextTag("color", "green"));
    }

    else
    {
        XRSettings.LoadDeviceByName("");
        _xrSettingsMgr.DeinitializeLoader();
        _xrSettingsMgr.StopSubsystems();
    }
}

Still, SteamVR should not launch automatically if autoEnableVR is false, but here we can see Unity is basically forcing VR to enable if you have any of its subsystems in your application at all.

Hopefully someone smarter than me knows what to do next, because that's all I got

zite commented 3 years ago

The auto enable vr checkbox is for enabling the steamvr subsystem in unity settings, not for launching it at runtime. Launching it at runtime is controlled by unity.

Mouledoux commented 3 years ago

Ok, but both are disabled, and it's still running. What's the proper way to prevent SteamVR from launching when my app does?

nitz commented 2 years ago

Hello @Mouledoux -- I just happened upon this issue while looking for something completely else. I agree with your assertion that SteamVR shouldn't launch if auto enable vr is false, and ran into the same problem myself. I discussed it on the Unity XR Plugin page, here: https://github.com/ValveSoftware/unity-xr-plugin/issues/80

@Verex found a solution that makes the OpenVR plugin obey the 'Initialize on Startup' option, and submitted it as a pull request here: https://github.com/ValveSoftware/unity-xr-plugin/pull/102

It hasn't been merged, or even acknowledged, but if you download their fork it works just like it says on the tin.

Peaj commented 2 years ago

This could also be connected to the problem I fixed with PR #974 (isn't merged yet) For me disabling autoEnableVR just didnt work as this setting always gets overwritten with the default value on each asset import.