void Awake() { //if an instance of this singleton does not exist, set the instance to this object and make it persist if (_instance == null) { _instance = this; DontDestroyOnLoad(this); } else { //if an instance of this singleton already exists, destroy this one if (_instance != this) { Destroy(this.gameObject); } } }
// Setup RenderManager for DirectMode or non-DirectMode rendering. // Checks to make sure Unity version and Graphics API are supported, // and that a RenderManager config file is being used. void InitRenderManager() { //check if we are configured to use RenderManager or not string renderManagerPath = _clientKit.context.getStringParameter("/renderManagerConfig"); _renderManagerConfigFound = !(renderManagerPath == null || renderManagerPath.Equals("")); if (_renderManagerConfigFound) { //found a RenderManager config _renderManager = GameObject.FindObjectOfType <OsvrRenderManager>(); if (_renderManager == null) { GameObject renderManagerGameObject = new GameObject("RenderManager"); //add a RenderManager component _renderManager = renderManagerGameObject.AddComponent <OsvrRenderManager>(); } //check to make sure Unity version and Graphics API are supported bool supportsRenderManager = _renderManager.IsRenderManagerSupported(); _renderManagerConfigFound = supportsRenderManager; if (!_renderManagerConfigFound) { Debug.LogError("[OSVR-Unity] RenderManager config found but RenderManager is not supported."); Destroy(_renderManager); } else { // attempt to create a RenderManager in the plugin int result = _renderManager.InitRenderManager(); if (result != 0) { Debug.LogError("[OSVR-Unity] Failed to create RenderManager."); _renderManagerConfigFound = false; VRSettings.enabled = false; //disable VR mode } } } else { Debug.Log("[OSVR-Unity] RenderManager config not detected. Using normal Unity rendering path."); } }
// Setup RenderManager for DirectMode or non-DirectMode rendering. // Checks to make sure Unity version and Graphics API are supported, // and that a RenderManager config file is being used. void SetupRenderManager() { //check if we are configured to use RenderManager or not string renderManagerPath = _clientKit.context.getStringParameter("/renderManagerConfig"); _useRenderManager = !(renderManagerPath == null || renderManagerPath.Equals("")); if (_useRenderManager) { //found a RenderManager config _renderManager = GameObject.FindObjectOfType<OsvrRenderManager>(); if (_renderManager == null) { //add a RenderManager component _renderManager = gameObject.AddComponent<OsvrRenderManager>(); } //check to make sure Unity version and Graphics API are supported bool supportsRenderManager = _renderManager.IsRenderManagerSupported(); _useRenderManager = supportsRenderManager; if (!_useRenderManager) { Debug.LogError("RenderManager config found but RenderManager is not supported."); Destroy(_renderManager); } else { // attempt to create a RenderManager in the plugin int result = _renderManager.InitRenderManager(); if (result != 0) { Debug.LogError("Failed to create RenderManager."); _useRenderManager = false; } } } else { Debug.Log("RenderManager config not detected. Using normal Unity rendering path."); } }