Home > Blockchain >  UnityEditor.PlayerSettings.virtualRealitySupported depreciated fix to statement
UnityEditor.PlayerSettings.virtualRealitySupported depreciated fix to statement

Time:07-29

Im trying to fix this section of code that has depreciated. The commented out section is the old code.

        public static bool isSinglePassStereoSelected
        {
            get
            {
                return XRSettings.enabled && XRSettings.StereoRenderingMode == XRSettings.StereoRenderingMode.SinglePass;
                
                //return UnityEditor.PlayerSettings.virtualRealitySupported
                //    && UnityEditor.PlayerSettings.stereoRenderingPath == UnityEditor.StereoRenderingPath.SinglePass;
            }
        }

Unity is currently in Safe Mode due to errors from importing this project into a new version of unity. I would prefer not using an older version of Unity to view this project.

I have been working through the project correcting errors and using it as a learning process.

My goal is to restore the function of this section of code without having to do extensive restructuring of the code as whole, as I don't believe this is a necessary component of the project/game to function but included as a standard practice, etc.

Commenting out this section creates more errors as it is referenced in other places. (I dont like this option as it just temporarily removes the problem.)

The line of code "return XRSetti..." is my attempt at updating the code to the new non-depreciated version of the code per Unity Recommendations shown below.

Before Depreciated Message

After Error Message

My coding terminology is lacking so it is making it difficult for me to find a reference to use, and understand how to correct this error.

Any references for reading/learning as to how this statement functions and why it isnt returning the desired result are welcome.

I believe the original purpose of this code was to check if VR was enabled and if a specific rendering mode was selected (SinglePass) by reference and return a true or false value that is stored as a bool labeled isSinglePassStereoSelected.

Unity Reference for StereoRenderingMode

Im not sure how to go about getting the returned information out of the XRSettings.StereoRenderingMode to be comparable to the SinglePass option.

The info from XRSettings is read-only and most solutions involved removing static from the stored value. I dont believe this applies because I can not edit the XRSettings variables, and the static bool applied to isSinglePassStereoSelected is not the reason for the error. (Removing static did not fix the problem and created another error)

Stack overflow remove static

Removed Static Error

I appreciate any help on how to approach this problem and find a solution.

Thanks in advance.

P.S.

Had to change images to links due to not having enough reputation, thanks for understanding.

Reference to setting that no longer appears in Project Settings

Edit:

XRSettings Unity Reference

Some words for readability.

CodePudding user response:

You have a capital "S" in XRSettings.StereoRenderingMode when trying to access the value of the project setting. The documentation for that field uses a lower case "s" as in XRSettings.stereoRenderingMode.

It's confusing because the version with a capital "S" is still a valid symbol because that's how the returned enum type is defined.

TLDR:

XRSettings.stereoRenderingMode is the getter for the settings XRSettings.StereoRenderingMode is the enum type

  • Related