public void ManualMainCameraRefresh()
        {
            TestUtils.CreateMainCamera();
            var unused           = CameraCache.Main;
            var secondMainCamera = TestUtils.CreateMainCamera();

            CameraCache.Refresh(secondMainCamera);
            Assert.That(CameraCache.Main, Is.EqualTo(secondMainCamera));
        }
        public void ManualMainCameraRefreshGetFirstAfterDelete()
        {
            var mainCamera       = TestUtils.CreateMainCamera();
            var unused           = CameraCache.Main;
            var secondMainCamera = TestUtils.CreateMainCamera();

            CameraCache.Refresh(secondMainCamera);
            Object.DestroyImmediate(secondMainCamera.gameObject);
            Assert.That(CameraCache.Main, Is.EqualTo(mainCamera));
        }
Пример #3
0
    void Start()
    {
        var mainCamera = CameraCache.Refresh(Camera.main);

        if (mainCamera == null)
        {
            Debug.LogWarning("Could not find a valid \"MainCamera\"!  Unable to update camera position.");
        }
        else
        {
            mainCamera.transform.position = Vector3.zero;
        }
    }
Пример #4
0
        protected virtual void LoadScene(int sceneName)
        {
            Destroy(camera.transform.parent.gameObject);
            Destroy(cursor.gameObject);
            Destroy(input.gameObject);

            // Avoids the error that is caused by the absence of the camera in the scene.
            Camera cam = gameObject.AddComponent <Camera>();

            cam.backgroundColor = Color.black;
            CameraCache.Refresh(cam);

            SceneManager.LoadScene(sceneName);
        }
        protected virtual void LoadScene(string sceneName)
        {
            Destroy(camera.transform.parent.gameObject);
            Destroy(cursor.gameObject);
            Destroy(input.gameObject);

            // Avoids the error that is caused by the absence of the camera in the scene.
            Camera cam = gameObject.AddComponent <Camera> ();

            cam.backgroundColor = Color.black;
            CameraCache.Refresh(cam);

        #if UNITY_5_3 || UNITY_5_3_OR_NEWER
            SceneManager.LoadScene(sceneName);
        #else
            Application.LoadLevel(sceneName);
        #endif
        }
Пример #6
0
        protected override void ApplySettings()
        {
            if (Values[SceneSetting.AddMixedRealityCamera])
            {
                if (CameraCache.Main != null)
                {
                    DestroyImmediate(CameraCache.Main.gameObject.GetParentRoot());
                }

                PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath <GameObject>(AssetDatabase.GUIDToAssetPath(CameraPrefabGUID)));
            }

            if (Values[SceneSetting.CameraToOrigin])
            {
                var mainCamera = CameraCache.Refresh(Camera.main);

                if (mainCamera == null)
                {
                    Debug.LogWarning("Could not find a valid \"MainCamera\"!  Unable to update camera position.");
                }
                else
                {
                    mainCamera.transform.position = Vector3.zero;
                }
            }

            if (Values[SceneSetting.AddInputSystem])
            {
                var inputManager = FindObjectOfType <InputManager>();
                if (inputManager != null)
                {
                    DestroyImmediate(inputManager.gameObject);
                }

                var eventSystems = FindObjectsOfType <EventSystem>();
                foreach (var eventSystem in eventSystems)
                {
                    DestroyImmediate(eventSystem.gameObject);
                }

                var inputModules = FindObjectsOfType <StandaloneInputModule>();
                foreach (var inputModule in inputModules)
                {
                    DestroyImmediate(inputModule.gameObject);
                }

                PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath <GameObject>(AssetDatabase.GUIDToAssetPath(InputSystemPrefabGUID)));
                Values[SceneSetting.UpdateCanvases] = true;
            }

            if (Values[SceneSetting.UpdateCanvases])
            {
                var focusManager = FindObjectOfType <FocusManager>();
                if (focusManager != null)
                {
                    FocusManager.Instance.UpdateCanvasEventSystems();
                }

                var sceneCanvases = Resources.FindObjectsOfTypeAll <Canvas>();
                foreach (Canvas canvas in sceneCanvases)
                {
                    var helper = canvas.EnsureComponent <CanvasHelper>();
                    helper.Canvas = canvas;
                }
            }

            if (Values[SceneSetting.AddDefaultCursor])
            {
                var cursors = FindObjectsOfType <BaseCursor>();
                foreach (var cursor in cursors)
                {
                    DestroyImmediate(cursor.gameObject.GetParentRoot());
                }

                PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath <GameObject>(AssetDatabase.GUIDToAssetPath(DefaultCursorPrefabGUID)));

                FindObjectOfType <InputManager>().GetComponent <SimpleSinglePointerSelector>().Cursor = FindObjectOfType <BaseCursor>();
            }

            EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());

            Close();
        }