public static void SetSpectatorMode(Mode NewMode) { if (mCurrentMode == NewMode) { return; } mCurrentMode = NewMode; switch (mCurrentMode) { case Mode.Free: RestorePreviousCamera(); if (mSpectatorCameras.Count > 0) { mCurrentSpectatorCamera = mSpectatorCameras[Random.Range(0, mSpectatorCameras.Count)]; if (null != mCurrentSpectatorCamera) { mPreviousCamera = Camera.main; mCurrentSpectatorCamera.Activate(true); if (null != mPreviousCamera) { mPreviousCamera.enabled = false; SetupAudioListeners(mPreviousCamera.gameObject, false); } } } break; case Mode.FollowPlayer: RestorePreviousCamera(); break; default: RestorePreviousCamera(); mAutoSwitch = true; break; } }
static void RestorePreviousCamera() { if (null != mPreviousCamera) { mPreviousCamera.enabled = true; SetupAudioListeners(mPreviousCamera.gameObject, true); if (null != mCurrentSpectatorCamera) { mCurrentSpectatorCamera.Activate(false); mCurrentSpectatorCamera = null; } mPreviousCamera = null; } }