Example #1
0
        private void previewCameraFade(AMITarget itarget, float frame, AMCameraSwitcherKey action)
        {
            // if transition is None, show end camera / color
            if (action.cameraFadeType == (int)AMCameraSwitcherKey.Fade.None)
            {
                // reset camera fade if visible
                // camera
                if (action.typeEnd == 0)
                {
                    Camera endCam = action.getCameraEnd(itarget);
                    if (endCam)
                    {
                        Utility.SetTopCamera(endCam, GetCachedCameras(itarget));
                    }
                    AMCameraFade.reset();
                }
                else
                {
                    showColor(action.colorEnd);
                }
                return;
            }
            // Get camerafade
            AMCameraFade cf = AMCameraFade.getCameraFade();

            cf.isReset = false;
            bool isReversed       = action.isReversed();
            int  firstTargetType  = (isReversed ? action.typeEnd : action.type);
            int  secondTargetType = (isReversed ? action.type : action.typeEnd);

            // Set render texture or colors if render texture is used
            setRenderTexture(itarget, cf, frame, firstTargetType, secondTargetType, isReversed, action);
            setColors(cf, firstTargetType, secondTargetType, isReversed, action);

            if (cf.irisShape != action.irisShape)
            {
                cf.irisShape = action.irisShape;
            }
            cf.mode = action.cameraFadeType;
            cf.setupMaterials();
            cf.r = action.cameraFadeParameters.ToArray();

            float t = (float)(frame - action.frame) / (float)(action.endFrame - action.frame);

            float percentage;

            if (action.hasCustomEase())
            {
                percentage = Utility.EaseCustom(0.0f, 1.0f, t, action.easeCurve);
            }
            else
            {
                var ease = Utility.GetEasingFunction((Ease)action.easeType);
                percentage = ease(t, 1.0f, action.amplitude, action.period);
            }

            cf.value   = 1.0f - percentage;
            cf.percent = percentage;
        }
        void CameraGenerateFadeTargets(bool isReversed, Camera cam, Camera camEnd, Camera[] allCams, float[] parameters)
        {
            AMCameraFade cf = AMCameraFade.getCameraFade();

            cf.incrementKeepAlives(true);

            if (cf.keepAliveColor)
            {
                cf.keepAliveColor = false;
            }
            cf.isReset = false;

            Camera firstCamera  = null;
            Camera secondCamera = null;
            Color? firstColor   = null;
            Color? secondColor  = null;

            if (isReversed)
            {
                if (camEnd)
                {
                    firstCamera = camEnd;
                }
                else if (typeEnd == 1)
                {
                    firstColor = colorEnd;
                }
                if (cam)
                {
                    secondCamera = cam;
                }
                else if (type == 1)
                {
                    secondColor = color;
                }
            }
            else
            {
                if (cam)
                {
                    firstCamera = cam;
                }
                else if (type == 1)
                {
                    firstColor = color;
                }
                if (camEnd)
                {
                    secondCamera = camEnd;
                }
                else if (typeEnd == 1)
                {
                    secondColor = colorEnd;
                }
            }
            // setup first target
            if (firstCamera)
            {
                // camera
                if (!still)
                {
                    cf.setupRenderTexture(firstCamera);
                }
                else
                {
                    AMUtil.SetTopCamera(firstCamera, allCams);
                    firstCamera.Render();
                    cf.refreshScreenTex();
                    cf.useRenderTexture = false;
                    cf.hasColorTex      = false;
                }
            }
            else
            {
                // color
                cf.colorTex    = (Color)firstColor;
                cf.hasColorTex = true;
            }
            // setup second target
            if (secondCamera)
            {
                // camera
                AMUtil.SetTopCamera(secondCamera, allCams);
                cf.hasColorBG = false;
            }
            else
            {
                // color
                cf.colorBG    = (Color)secondColor;
                cf.hasColorBG = true;
            }
            // iris shape
            if (irisShape)
            {
                cf.irisShape = irisShape;
                //cf.setupMaterials();
            }
            cf.mode = cameraFadeType;
            // setup camera fade
            cf.setupMaterials();
            cf.r       = parameters;
            cf.value   = 1f;
            cf.percent = 0f;
        }