// -- Methods -- public void Fade(int cameraKey, bool fadeOut, Action fadeCallback) { Camera Cam = RegisteredObjects[cameraKey]; CameraFader Fader = Cam.GetComponent <CameraFader>(); MyContract.RequireFieldNotNull( Fader, "Camera " + cameraKey + "\'s Fader" ); if (fadeOut) { Fader.FadeToBlack(fadeCallback); } else { Fader.FadeToClear(fadeCallback); } }
private void FadeAll(FadeFunction fadeFunction, Action fadeCallback) { MyContract.RequireFieldNotNull(CoroutineHost, "CoroutineHost"); HashSet <int> ObjectsToFade = new HashSet <int>(); HashSet <int> FadedObjectsFlag = new HashSet <int>(); foreach (var entry in RegisteredObjects) { Camera Cam = entry.Value; int Key = entry.Key; CameraFader FadeComponent = Cam.gameObject.GetComponent <CameraFader>(); if (FadeComponent != null) { ObjectsToFade.Add(Key); Action PartialFadeCallback = delegate() { FadedObjectsFlag.Add(Key); }; fadeFunction(FadeComponent, PartialFadeCallback); } else { //Debug.Log("Camera " // + Cam.gameObject.name // + " has no Camera Fader - Skipping"); } } if (fadeCallback != null) { CoroutineHost.StartCoroutine( FadeCallbackCoroutine( ObjectsToFade, FadedObjectsFlag, fadeCallback ) ); } }
private void InitialiseScreenFader() { CameraRegistry.CoroutineHost = this; ScreenFadeImageHost .transform .SetParent(PlayerScreenCanvas.transform, false); CameraFader Fader = CameraRegistry[(int)CameraRoles.FixedUi] .GetComponent <CameraFader>(); MyContract.RequireFieldNotNull( Fader, "Fixed UI CameraFader component" ); Fader.FadeImg = ScreenFadeImageHost.GetComponent <Image>(); MyContract.RequireFieldNotNull( Fader.FadeImg, "ScreenFadeImageHost Image component" ); PlayerScreenCanvas .GetComponent <ScreenSizeChangeTrigger>() .ScreenResizedInternal .AddListener(Fader.OnScreenSizeChange); Fader.OnScreenSizeChange(PlayerScreenCanvas.GetComponent <RectTransform>().rect); }