/// <summary> /// Unsnap the head camera rig from scope view /// </summary> private void UnsnapViewFromScope() { Debug.Log("Unsnapping from scope view."); ViewSnapped = false; try { HideIcons(); Camera headCam = HeadCamRig.GetComponent <Camera>(); DisableCullingMaskLayer("Perspective_Only", headCam); DisableCullingMaskLayer("Micro", headCam); EnableCullingMaskLayer("Macro", headCam); } catch (NullReferenceException) { Debug.Log("Head camera could not be found."); } }
/// <summary> /// Snap the head camera rig to scope view /// </summary> private void SnapViewToScope() { Debug.Log("Snapping to scope view."); ViewSnapped = true; try { HideIcons(); GameObject lockedPerspectiveObj = HeadCamRig.transform.FindChild("LockedScopePerspective").gameObject; Camera scopeCam = GameObject.FindWithTag("ScopeCam").GetComponent <Camera>(); //Set scope camera to render to locked perspective texture scopeCam.targetTexture = lockedPerspectiveObj.GetComponent <MeshRenderer>().material.mainTexture as RenderTexture; //Set head cam to render only micro layer (incl. locked perspective object) Camera headCam = HeadCamRig.GetComponent <Camera>(); DisableCullingMaskLayer("Macro", headCam); EnableCullingMaskLayer("Micro", headCam); EnableCullingMaskLayer("Perspective_Only", headCam); } catch (NullReferenceException) { Debug.Log("Locked scope perspective target or scope camera was not found."); } }
private IEnumerator UITransitionIn(Collider other) { System.DateTime tPointOfNoReturn = System.DateTime.Now.AddSeconds(TransitionWaitTime); while (System.DateTime.Now < tPointOfNoReturn) { //Ensure colliders are still colliding - if not, cancel transition if (!other.bounds.Intersects(GetComponent <Collider>().bounds)) { BreakTransition(); } //Raise icon alpha _scopeIcon.color = new Color(1, 1, 1, Mathf.Lerp(_scopeIcon.color.a, 1.5f, Time.deltaTime)); yield return(new WaitForEndOfFrame()); } //Fade to black System.DateTime tFadeBlackFinish = System.DateTime.Now.AddSeconds(FadeDuration); while (System.DateTime.Now < tFadeBlackFinish) { _fullViewCover.color = new Color(0, 0, 0, Mathf.Lerp(_fullViewCover.color.a, 2.0f, Time.deltaTime * 2)); yield return(new WaitForEndOfFrame()); } DisableCullingMaskLayer("Macro", HeadCamRig.GetComponent <Camera>()); SnapViewToScope(); //Fade in to micro view System.DateTime tFadeInFinish = System.DateTime.Now.AddSeconds(FadeDuration); while (System.DateTime.Now < tFadeInFinish) { _fullViewCover.color = new Color(0, 0, 0, Mathf.Lerp(_fullViewCover.color.a, -1.0f, Time.deltaTime)); yield return(new WaitForEndOfFrame()); } UITransitionFlag = false; yield return(null); }