// draw the gui public void DrawGUI() { if (Application.isPlaying) { Color previousColor = GUI.backgroundColor; #if UNITY_EDITOR DrawDebugData(); #endif if (eDebugCameraType.FlyCamera == debugCamera) { GUI.backgroundColor = Color.red; if (GUILayout.Button("Turn Off Debug Fly Cam")) { debugCamera = eDebugCameraType.None; } } else // not fly camera { GUI.backgroundColor = Color.green; if (GUILayout.Button("Turn On Debug Fly Cam")) { debugCamera = eDebugCameraType.FlyCamera; } } GUI.backgroundColor = previousColor; } }
private void InternalUpdate(float deltaTime) { UpdateGameCamera(deltaTime); if (_isCinematicActive) { Vector3 tempPosition = Vector3.zero; Quaternion tempQuat = Quaternion.identity; Cinematic.GetCurrentCinematicTransform(ref tempPosition, ref tempQuat); transform.position = tempPosition; transform.rotation = tempQuat; } if (_isStillCamActive) { transform.position = _stillCameraPosition; transform.rotation = _stillCameraRotation; } #if DEBUG // if we are turning the debug camera on if (_previousFrameDebugCamera != debugCamera && eDebugCameraType.None == _previousFrameDebugCamera) { _debugCameraPosition = transform.position; _debugCameraRotation = transform.rotation; } switch (debugCamera) { case eDebugCameraType.SceneCamera: if (null != Camera.current && null != Camera.current.transform) { _debugCameraPosition = Camera.current.transform.position; _debugCameraRotation = Camera.current.transform.rotation; } break; case eDebugCameraType.FlyCamera: UpdateDebugFlyCamera(); break; default: break; } if (eDebugCameraType.None != debugCamera) { transform.position = _debugCameraPosition; transform.rotation = _debugCameraRotation; } _previousFrameDebugCamera = debugCamera; #endif }
void OnEnable() { #if DEBUG //DebugSystem.RegisterSystem("Camera", this); debugCamera = _previousFrameDebugCamera = eDebugCameraType.None; #endif OnComponentEnable(); #if UNITY_EDITOR if (!Application.isPlaying) { //EditorApplication.update += EditorUpdate; } #endif }
void Start() { if (!Application.isPlaying) { return; } _rayHitDistComparer = new RayHitDistComparer(); OnComponentStart(); SetFieldOfView(); // called at this point to ensure levels created with the old field of view are updated SetZoonSpeed(); _mainCamera = MainCamera; #if DEBUG debugCamera = _previousFrameDebugCamera = eDebugCameraType.None; #endif }
private static void SetDebugCamera(eDebugCameraType type) { CameraBase cameraComponent = null; if (Application.isPlaying) { if (null != Camera.main && null != Camera.main.gameObject) { cameraComponent = Camera.main.gameObject.GetComponent <CameraBase>(); } } else { cameraComponent = GameObject.FindObjectOfType(typeof(CameraBase)) as CameraBase; } if (null != cameraComponent) { cameraComponent.debugCamera = type; } }