private void InitOVRManager()

in RealityMaterialExplorer/Assets/Oculus/VR/Scripts/OVRManager.cs [1344:1510]


	private void InitOVRManager()
	{
		// Only allow one instance at runtime.
		if (instance != null)
		{
			enabled = false;
			DestroyImmediate(this);
			return;
		}

		instance = this;

		// uncomment the following line to disable the callstack printed to log
		//Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None);  // TEMPORARY

		Debug.Log("Unity v" + Application.unityVersion + ", " +
				"Oculus Utilities v" + OVRPlugin.wrapperVersion + ", " +
				"OVRPlugin v" + OVRPlugin.version + ", " +
				"SDK v" + OVRPlugin.nativeSDKVersion + ".");

		Debug.LogFormat("SystemHeadset {0}, API {1}", systemHeadsetType.ToString(), xrApi.ToString());

		if (xrApi == XrApi.OpenXR)
		{
			Debug.LogFormat("OpenXR instance 0x{0:X} session 0x{1:X}", xrInstance, xrSession);
		}

#if !UNITY_EDITOR
		if (IsUnityAlphaOrBetaVersion())
		{
			Debug.LogWarning(UnityAlphaOrBetaVersionWarningMessage);
		}
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
		var supportedTypes =
			UnityEngine.Rendering.GraphicsDeviceType.Direct3D11.ToString() + ", " +
			UnityEngine.Rendering.GraphicsDeviceType.Direct3D12.ToString();

		if (!supportedTypes.Contains(SystemInfo.graphicsDeviceType.ToString()))
			Debug.LogWarning("VR rendering requires one of the following device types: (" + supportedTypes + "). Your graphics device: " + SystemInfo.graphicsDeviceType.ToString());
#endif

		// Detect whether this platform is a supported platform
		RuntimePlatform currPlatform = Application.platform;
		if (currPlatform == RuntimePlatform.Android ||
			// currPlatform == RuntimePlatform.LinuxPlayer ||
			currPlatform == RuntimePlatform.OSXEditor ||
			currPlatform == RuntimePlatform.OSXPlayer ||
			currPlatform == RuntimePlatform.WindowsEditor ||
			currPlatform == RuntimePlatform.WindowsPlayer)
		{
			isSupportedPlatform = true;
		}
		else
		{
			isSupportedPlatform = false;
		}
		if (!isSupportedPlatform)
		{
			Debug.LogWarning("This platform is unsupported");
			return;
		}

#if UNITY_ANDROID && !UNITY_EDITOR
		// Turn off chromatic aberration by default to save texture bandwidth.
		chromatic = false;
#endif

#if (UNITY_STANDALONE_WIN || UNITY_ANDROID) && !UNITY_EDITOR
		enableMixedReality = false;		// we should never start the standalone game in MxR mode, unless the command-line parameter is provided
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
		if (!staticMixedRealityCaptureInitialized)
		{
			bool loadMrcConfig = LoadMixedRealityCaptureConfigurationFileFromCmd();
			bool createMrcConfig = CreateMixedRealityCaptureConfigurationFileFromCmd();

			if (loadMrcConfig || createMrcConfig)
			{
				OVRMixedRealityCaptureSettings mrcSettings = ScriptableObject.CreateInstance<OVRMixedRealityCaptureSettings>();
				mrcSettings.ReadFrom(this);
				if (loadMrcConfig)
				{
					mrcSettings.CombineWithConfigurationFile();
					mrcSettings.ApplyTo(this);
				}
				if (createMrcConfig)
				{
					mrcSettings.WriteToConfigurationFile();
				}
				ScriptableObject.Destroy(mrcSettings);
			}

			if (MixedRealityEnabledFromCmd())
			{
				enableMixedReality = true;
			}

			if (enableMixedReality)
			{
				Debug.Log("OVR: Mixed Reality mode enabled");
				if (UseDirectCompositionFromCmd())
				{
					compositionMethod = CompositionMethod.Direct;
				}
				if (UseExternalCompositionFromCmd())
				{
					compositionMethod = CompositionMethod.External;
				}
				Debug.Log("OVR: CompositionMethod : " + compositionMethod);
			}
		}
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || OVR_ANDROID_MRC
		StaticInitializeMixedRealityCapture(this);
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
		if (enableAdaptiveResolution && !OVRManager.IsAdaptiveResSupportedByEngine())
		{
			enableAdaptiveResolution = false;
			UnityEngine.Debug.LogError("Your current Unity Engine " + Application.unityVersion + " might have issues to support adaptive resolution, please disable it under OVRManager");
		}
#endif

		Initialize();

		Debug.LogFormat("Current display frequency {0}, available frequencies [{1}]",
			display.displayFrequency, string.Join(", ", display.displayFrequenciesAvailable.Select(f => f.ToString()).ToArray()));

		if (resetTrackerOnLoad)
			display.RecenterPose();

		if (Debug.isDebugBuild)
		{
			// Activate system metrics collection in Debug/Developerment build
			if (GetComponent<OVRSystemPerfMetrics.OVRSystemPerfMetricsTcpServer>() == null)
			{
				gameObject.AddComponent<OVRSystemPerfMetrics.OVRSystemPerfMetricsTcpServer>();
			}
			OVRSystemPerfMetrics.OVRSystemPerfMetricsTcpServer perfTcpServer = GetComponent<OVRSystemPerfMetrics.OVRSystemPerfMetricsTcpServer>();
			perfTcpServer.listeningPort = profilerTcpPort;
			if (!perfTcpServer.enabled)
			{
				perfTcpServer.enabled = true;
			}
#if !UNITY_EDITOR
			OVRPlugin.SetDeveloperMode(OVRPlugin.Bool.True);
#endif
		}

		// Refresh the client color space
		OVRManager.ColorSpace clientColorSpace = colorGamut;
		colorGamut = clientColorSpace;

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
		// Force OcculusionMesh on all the time, you can change the value to false if you really need it be off for some reasons,
		// be aware there are performance drops if you don't use occlusionMesh.
		OVRPlugin.occlusionMesh = true;
#endif

		OVRManagerinitialized = true;

	}