Ejemplo n.º 1
0
    private void previewCameraFade(float frame, AMCameraSwitcherAction action, bool isPreview)
    {
        // if transition is None, show end camera / color
        if (action.cameraFadeType == (int)AMTween.Fade.None)
        {
            // reset camera fade if visible
            // camera
            if (action.endTargetType == 0)
            {
                if (action.endCamera)
                {
                    AMTween.SetTopCamera(action.endCamera, cachedAllCameras);
                }
                AMCameraFade.reset();
            }
            else
            {
                showColor(action.endColor, isPreview);
            }
            return;
        }
        // Get camerafade
        AMCameraFade cf = AMCameraFade.getCameraFade(isPreview);

        if (Application.isPlaying)
        {
            cf.keepAlivePreview = true;
        }
        cf.isReset = false;
        bool isReversed       = action.isReversed();
        int  firstTargetType  = (isReversed ? action.endTargetType : action.startTargetType);
        int  secondTargetType = (isReversed ? action.startTargetType : action.endTargetType);

        // Set render texture or colors if render texture is used
        setRenderTexture(cf, frame, firstTargetType, secondTargetType, isReversed, action, isPreview);
        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();

        // calculate and set value
        AMTween.EasingFunction ease;
        AnimationCurve         curve = null;

        if (action.hasCustomEase())
        {
            ease  = AMTween.customEase;
            curve = action.easeCurve;
        }
        else
        {
            ease = AMTween.GetEasingFunction((AMTween.EaseType)action.easeType);
        }
        float percentage = (float)(frame - action.startFrame) / (float)(action.endFrame - action.startFrame);
        float value      = ease(1f, 0f, percentage, curve);

        cf.value   = value;
        cf.percent = percentage;
    }
Ejemplo n.º 2
0
    public override void previewFrame(float frame, AMTrack extraTrack = null)
    {
        if (cache == null || cache.Count <= 0)
        {
            return;
        }

        bool isPreview = !Application.isPlaying;

        //GameObject go = GameObject.Find ("AMCameraFade");
        //AMCameraFade cf = null;
        //if(go) cf = (AMCameraFade) go.GetComponent(typeof(AMCameraFade));


        for (int i = 0; i < cache.Count; i++)
        {
            // before first frame
            if (frame <= (cache[i] as AMCameraSwitcherAction).startFrame)
            {
                //if(cf) DestroyImmediate(cf.gameObject);
                AMCameraFade.reset();
                if (!(cache[i] as AMCameraSwitcherAction).hasStartTarget())
                {
                    return;
                }

                if ((cache[i] as AMCameraSwitcherAction).startTargetType == 0)
                {
                    //(cache[i] as AMCameraSwitcherAction).startCamera.targetTexture = null;
                    AMTween.SetTopCamera((cache[i] as AMCameraSwitcherAction).startCamera, cachedAllCameras);
                }
                else
                {
                    showColor((cache[i] as AMCameraSwitcherAction).startColor, isPreview);
                    // or color # TO DO #
                }

                return;
                // between first and last frame
            }
            else if (frame <= (cache[i] as AMCameraSwitcherAction).endFrame)
            {
                if (!(cache[i] as AMCameraSwitcherAction).hasStartTarget() || !(cache[i] as AMCameraSwitcherAction).hasEndTarget())
                {
                    return;
                }
                // targets are equal
                if ((cache[i] as AMCameraSwitcherAction).targetsAreEqual())
                {
                    //if(cf) DestroyImmediate(cf.gameObject);
                    AMCameraFade.reset();
                    if ((cache[i] as AMCameraSwitcherAction).startTargetType == 0)
                    {
                        // use camera (cache[i] as AMCameraSwitcherAction) startTarget
                        //(cache[i] as AMCameraSwitcherAction).startCamera.targetTexture = null;
                        // if not first frame, set top camera
                        AMTween.SetTopCamera((cache[i] as AMCameraSwitcherAction).startCamera, cachedAllCameras);
                    }
                    else
                    {
                        showColor((cache[i] as AMCameraSwitcherAction).startColor, isPreview);
                        // or color # TO DO #
                    }
                }
                else
                {
                    //if((cache[i] as AMCameraSwitcherAction).endTargetType == 0) (cache[i] as AMCameraSwitcherAction).endCamera.targetTexture = null;
                    AMCameraFade.clearRenderTexture();
                    // preview transition: (cache[i] as AMCameraSwitcherAction).cameraFadeType
                    previewCameraFade(frame, (cache[i] as AMCameraSwitcherAction), isPreview);
                }
                return;
                // after last frame
            }
            else if (i == cache.Count - 2)
            {
                //if(cf) DestroyImmediate(cf.gameObject);
                AMCameraFade.reset();
                if (!(cache[i] as AMCameraSwitcherAction).hasEndTarget())
                {
                    return;
                }
                // use camera (cache[i] as AMCameraSwitcherAction) endTarget
                if ((cache[i] as AMCameraSwitcherAction).endTargetType == 0)
                {
                    // use camera (cache[i] as AMCameraSwitcherAction) startTarget
                    //(cache[i] as AMCameraSwitcherAction).endCamera.targetTexture = null;
                    AMTween.SetTopCamera((cache[i] as AMCameraSwitcherAction).endCamera, cachedAllCameras);
                }
                else
                {
                    showColor((cache[i] as AMCameraSwitcherAction).endColor, isPreview);
                    // or color # TO DO #
                }
                return;
            }
        }
    }