Ejemplo n.º 1
0
        } //END _SetVRMode

        //----------------------------------//
        private IEnumerator LoadDevice( string newDevice, bool vrModeActive, bool useGazeInput, bool useMouseInput, bool useTouchInput )
        //----------------------------------//
        {
            //If we're using a VR view, force the view into landscape left to prevent a camera FOV bug
            if( newDevice != "none" && Screen.orientation != ScreenOrientation.LandscapeLeft )
            {
                Screen.orientation = ScreenOrientation.LandscapeLeft;
                yield return new WaitForSeconds(.1f);
                if( showDebug ) Debug.Log( "LoadDevice( split ), Set Screen.orientation to LandscapeLeft" );
            }
            else
            {
                if( showDebug ) Debug.Log( "LoadDevice( " + newDevice + " ) else" );
            }


            if( UnityEngine.XR.XRSettings.loadedDeviceName != newDevice )
            {
                yield return null;
                UnityEngine.XR.XRSettings.LoadDeviceByName( newDevice );
                if( showDebug ) Debug.Log( "XRMode.cs LoadDevice( " + newDevice + " ), VRSettings.enabled = " + vrModeActive );
            }

            yield return null;

            if( newDevice == "none" )
            {
                Screen.autorotateToLandscapeLeft = true;
                Screen.autorotateToLandscapeRight = true;
                Screen.autorotateToPortrait = true;
                Screen.autorotateToPortraitUpsideDown = true;
                Screen.orientation = ScreenOrientation.AutoRotation;
                yield return new WaitForSeconds( .1f );
                if( showDebug ) Debug.Log( "LoadDevice( none ), Set Screen.orientation to Auto" );
            }

            UnityEngine.XR.XRSettings.enabled = vrModeActive;

            //Set the currentHelper to the latest settings
            XRModeHelper.XRDevices deviceType = XRModeHelper.XRDevices.none;

            if( GetCurrentXRDevice( out deviceType ) )
            {
                currentHelper = new XRModeHelper( Application.platform, deviceType, vrModeActive, useGazeInput, useMouseInput, useTouchInput );
            }
            
            //Force cameras to deal with aspect ratio changes
            if( Camera.allCameras != null )
            {
                foreach( Camera item in Camera.allCameras )
                {
                    item.ResetAspect();
                }
            }

            SetDistortionBasedOnSettings();

        } //END LoadDevice
Ejemplo n.º 2
0
        } //END Start

        //--------------------------------------//
        private void SetCurrentXRModeHelper()
        //--------------------------------------//
        {

            if( XRModeSettings != null && XRModeSettings.Count > 0 )
            {
                foreach( XRModeHelper helper in XRModeSettings )
                {
                    if( helper.PlatformType == Application.platform )
                    {
                        if( showDebug ) Debug.Log( "XRMode.cs SetCurrentXRModeHelper() found helper for Platform = " + Application.platform );
                        currentHelper = helper;
                        return;
                    }
                    else
                    {
                        if( showDebug ) Debug.Log( "XRMode.cs SetCurrentXRModeHelper() helper.Platform( " + helper.PlatformType + " ) != " + Application.platform );
                    }
                }
            }

            currentHelper = new XRModeHelper( Application.platform, XRModeHelper.XRDevices.none, false, false, true, true );

        } //END SetCurrentXRModeHelper