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

Importing a project in Unity 2020.3 causes SteamVR_Settings to reset #949

Open
viliusnbg opened this issue May 5, 2021 · 3 comments · May be fixed by #974
Open

Importing a project in Unity 2020.3 causes SteamVR_Settings to reset #949

viliusnbg opened this issue May 5, 2021 · 3 comments · May be fixed by #974
Labels
Has workaround Unity issue An issue that unity needs to fix

Comments

@viliusnbg
Copy link

Hi,

If you have a project that uses SteamVR and you try to import it with Unity 2020.3, the SteamVR_Settings get reset.

A simple usecase where this matters is cloning the project onto a new machine from github. When you clone the project, it needs to be imported into unity and it needs to generate the library folder and all the related settings.

At the end of the import, SteamVR_Settings.instance will be called. This will trigger LoadInstance() which calls Resources.Load("SteamVR_Settings"). Normally, this would load the existing settings, but for whatever reason during project import this will not load anything and return null. Then the default settings will be generated instead and the actual settings file will be overwritten.

This is a big issue as it also happens when automating unity builds, causing a misconfigured build, making automation impossible.

This might be a Unity bug on an intentional behaviour of Resouces.Load(). Regardless there is a workaround:

#if UNITY_EDITOR
            if (_instance == null)
            {
                _instance = UnityEditor.AssetDatabase.LoadAssetAtPath<SteamVR_Settings>("Assets/SteamVR_Resources/Resources/SteamVR_Settings.asset");
            }
#endif

Adding this snippet of code in the SteamVR_Settings.LoadInstance() allows steamvr to still load everything during project import.

Hope this issue can be fixed/worked around in the plugin itself.

@zite
Copy link
Collaborator

zite commented May 7, 2021

Thanks for finding this and reporting. That is definitely not what we would expect. I'm going to label this as a unity bug with a workaround as I believe it does not repro on other major versions.

I believe we support moving that file, so I'm not sure doing a load at path is the best plan for the plugin to implement, but is certainly valid on a case by case basis.

@zite zite added Has workaround Unity issue An issue that unity needs to fix labels May 7, 2021
@Peaj
Copy link

Peaj commented Jul 16, 2021

I reproduced the same issue with Unity 2019.4.28f1 LTS and it happens to me in a many other Unity versions as well.

Here is a repo with the repro case: https://github.com/Peaj/SteamVRBug
Its a simple project with the latest unitypackage (2.7.3) imported and the legacy VR dialog option accepted.
Just cloning and opening it results in a changed SteamVR_Settings file.

This is a major issue. Especially since it leads to resetting "autoEnableVR" to its default value of 1 which in turn leads to a change in the ProjectSettings.

It breaks CI pipelines and means you have to tell everyone to discard their changes after cloning the project.

Peaj added a commit to Peaj/SteamVRBug that referenced this issue Jul 16, 2021
@Peaj
Copy link

Peaj commented Jul 16, 2021

I also tested the workaround proposed by @viliusnbg: https://github.com/Peaj/SteamVRBug/tree/workaround
It does not work for me as LoadAssetAtPath also returns null.

Peaj added a commit to Smart-Cave-Solutions/steamvr_unity_plugin that referenced this issue Jul 23, 2021
As Resource.Load fails and returns null during asset import SteamVR_Settings.instance cannot be called from DidReloadScripts

Fixes ValveSoftware#949
zite added a commit that referenced this issue Feb 9, 2023
A Unity bug occurs when loading resources too quickly that caused steamvr settings to be erased. Thanks for the PR @Peaj #949
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Has workaround Unity issue An issue that unity needs to fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants