private void Update()
 {
     if (_camera.isActiveAndEnabled && !_isCameraSet)
     {
         GPUInstancerAPI.SetCamera(_camera);
         _isCameraSet = true;
     }
     else if (!_camera.isActiveAndEnabled && _isCameraSet)
     {
         _isCameraSet = false;
     }
 }
예제 #2
0
        private void SetCameraMode(CameraModes cameraMode)
        {
            if (!fpController || !spaceshipCamera || !grassMowerCamera)
            {
                Debug.Log("Not all cameras are set. Please assign the relevant cameras from the inspector");
                return;
            }

            fpController.SetActive(false);
            spaceshipCamera.SetActive(false);
            grassMowerCamera.SetActive(false);

            _spaceShip.GetComponent <SpaceshipController>().enabled = false;
            _spaceShipThrusterGlow.gameObject.SetActive(false);
            _spaceShipControlsText.gameObject.SetActive(false);

            _grassMower.GetComponent <GrassMowerController>().enabled        = false;
            _grassMower.GetComponent <GPUInstancerInstanceRemover>().enabled = false;
            _grassMowerControlsText.gameObject.SetActive(false);

            switch (cameraMode)
            {
            case CameraModes.FPMode:
                fpController.SetActive(true);
                _activeCameraGO = fpController;
                break;

            case CameraModes.SpaceshipMode:
                spaceshipCamera.SetActive(true);
                _spaceShip.GetComponent <SpaceshipController>().enabled = true;
                _spaceShipThrusterGlow.gameObject.SetActive(true);
                _spaceShipControlsText.gameObject.SetActive(true);
                _activeCameraGO = spaceshipCamera;
                break;

            case CameraModes.MowerMode:
                grassMowerCamera.SetActive(true);
                _grassMower.GetComponent <GrassMowerController>().enabled        = true;
                _grassMower.GetComponent <GPUInstancerInstanceRemover>().enabled = true;
                _grassMowerControlsText.gameObject.SetActive(true);
                _activeCameraGO = grassMowerCamera;
                break;
            }

            _currentCameraMode = cameraMode;

            // Notify GPU Instancer of the camera change:
            GPUInstancerAPI.SetCamera(_activeCameraGO.GetComponentInChildren <Camera>());
        }
예제 #3
0
        private void Update()
        {
            if (Input.GetKeyUp(KeyCode.C))
            {
                SwitchCameraMode();
            }

            if (Input.GetKeyUp(KeyCode.U))
            {
                _uiCanvas.gameObject.SetActive(!_uiCanvas.gameObject.activeSelf);
            }

            if (Input.GetKeyUp(KeyCode.F1))
            {
                if (detailManager.gameObject.activeSelf && persistRemoval)
                {
                    detailMapData = GPUInstancerAPI.GetDetailMapData(detailManager);
                }
                detailManager.gameObject.SetActive(!detailManager.gameObject.activeSelf);
                if (detailManager.gameObject.activeSelf)
                {
                    if (persistRemoval && detailMapData != null)
                    {
                        GPUInstancerAPI.SetDetailMapData(detailManager, detailMapData);
                    }
                    _loadingTerrainDetailsText.SetActive(true);
                    GPUInstancerAPI.SetCamera(_activeCameraGO.GetComponentInChildren <Camera>());
                    GPUInstancerAPI.StartListeningGPUIEvent(GPUInstancerEventType.DetailInitializationFinished, DisableLoadingTerrainDetailsText);
                }
                SetQualityMode(_currentQualityMode);
            }

            if (Input.GetKeyUp(KeyCode.F2))
            {
                SetQualityMode(QualityMode.Low);
            }

            if (Input.GetKeyUp(KeyCode.F3))
            {
                SetQualityMode(QualityMode.Mid);
            }

            if (Input.GetKeyUp(KeyCode.F4))
            {
                SetQualityMode(QualityMode.High);
            }
        }
예제 #4
0
        private void SwitchCameras()
        {
            if (!FpsController || !FixedCamera)
            {
                return;
            }
            FpsController.SetActive(isCurrentCameraFixed);
            FixedCamera.SetActive(!isCurrentCameraFixed);

            var managers = FindObjectsOfType <GPUInstancerDetailManager>();

            foreach (var manager in managers)
            {
                GPUInstancerAPI.SetCamera(isCurrentCameraFixed
                    ? FpsController.GetComponentInChildren <Camera>()
                    : FixedCamera.GetComponentInChildren <Camera>());
            }

            if (!isCurrentCameraFixed)
            {
                Cursor.lockState = CursorLockMode.None;
                Cursor.visible   = true;
            }
        }
예제 #5
0
 public void SetCamera(Camera camera)
 {
     cameraData.mainCamera = camera;
     GPUInstancerAPI.SetCamera(camera);
 }