コード例 #1
0
    public AnimationHandler AnimatePosition(Vector3 newPos, float duration, bool local = false, Tweener.InterpolationType interpolationType = Tweener.InterpolationType.LINEAR,
                                            Tweener.TweenerEventHandler onFinished     = null, float delay = 0f)
    {
        AnimationHandler animationHandler = new AnimationHandler();
        Vector3          currentPos       = transform.position;

        if (local)
        {
            currentPos = transform.localPosition;
        }

        if (Mathf.Abs(currentPos.x - newPos.x) > Tweener.MinTargetDifference)
        {
            tweeners.Add(new PositionTweener(this.gameObject, duration, Tweener.TweenerType.X, newPos.x, interpolationType, local, onFinished, delay));
            animationHandler.AddTweener(tweeners [tweeners.Count - 1]);
            onFinished = null;
        }

        if (Mathf.Abs(currentPos.y - newPos.y) > Tweener.MinTargetDifference)
        {
            tweeners.Add(new PositionTweener(this.gameObject, duration, Tweener.TweenerType.Y, newPos.y, interpolationType, local, onFinished, delay));
            animationHandler.AddTweener(tweeners [tweeners.Count - 1]);
            onFinished = null;
        }

        if (Mathf.Abs(currentPos.z - newPos.z) > Tweener.MinTargetDifference)
        {
            tweeners.Add(new PositionTweener(this.gameObject, duration, Tweener.TweenerType.Z, newPos.z, interpolationType, local, onFinished, delay));
            animationHandler.AddTweener(tweeners [tweeners.Count - 1]);
            onFinished = null;
        }

        return(animationHandler);
    }
コード例 #2
0
    public PositionTweener(GameObject gameObject, float duration, TweenerType tweenerType,
                           float targetValue, InterpolationType tweenerInterpolationType = InterpolationType.LINEAR, bool local = false,
                           Tweener.TweenerEventHandler onFinished = null, float delay = 0f)
    {
        float startValue = 0;

        if (tweenerType == TweenerType.X || tweenerType == TweenerType.Y || tweenerType == TweenerType.Z)
        {
            switch (tweenerType)
            {
            case TweenerType.X:

                if (local)
                {
                    startValue = gameObject.transform.localPosition.x;
                }
                else
                {
                    startValue = gameObject.transform.position.x;
                }

                break;

            case TweenerType.Y:

                if (local)
                {
                    startValue = gameObject.transform.localPosition.y;
                }
                else
                {
                    startValue = gameObject.transform.position.y;
                }

                break;

            case TweenerType.Z:

                if (local)
                {
                    startValue = gameObject.transform.localPosition.z;
                }
                else
                {
                    startValue = gameObject.transform.position.z;
                }

                break;
            }

            this.transform = gameObject.transform;
            this.local     = local;
            this.setup(gameObject, duration, targetValue, startValue, tweenerType, tweenerInterpolationType);
            this.OnTweenerFinished += onFinished;
            this.delay              = delay;
        }
        else
        {
            Cancel();
        }
    }
コード例 #3
0
    public CanvasAlphaTweener(GameObject gameObject, float duration,
                              float targetValue, InterpolationType tweenerInterpolationType = InterpolationType.LINEAR, float delay = 0f, Tweener.TweenerEventHandler onFinished = null)
    {
        canvas = gameObject.GetComponent <CanvasGroup> ();

        if (canvas != null)
        {
            float startValue = canvas.alpha;
            setup(gameObject, duration, targetValue, startValue, TweenerType.CANVAS_ALPHA, interpolationType, delay);
            this.OnTweenerFinished += onFinished;
        }
        else
        {
            Cancel();
        }
    }
コード例 #4
0
    public AnimationHandler AnimateCanvasGroupAlpha(float targetValue, float duration,
                                                    Tweener.InterpolationType interpolationType = Tweener.InterpolationType.LINEAR, float delay = 0f, Tweener.TweenerEventHandler onFinished = null)
    {
        AnimationHandler animationHandler = new AnimationHandler();
        CanvasGroup      canvasGroup      = this.gameObject.GetComponent <CanvasGroup> ();

        targetValue = Mathf.Clamp01(targetValue);

        if (canvasGroup != null)
        {
            if (Mathf.Abs(canvasGroup.alpha - targetValue) > Tweener.MinTargetDifference)
            {
                tweeners.Add(new CanvasAlphaTweener(this.gameObject, duration, targetValue, interpolationType, delay, onFinished));
                animationHandler.AddTweener(tweeners [tweeners.Count - 1]);
            }
        }

        return(animationHandler);
    }
コード例 #5
0
    public AnimationHandler TweeenValue(float startValue, float endValue, float duration, Tweener.TweenerEventHandler onUpdate,
                                        Tweener.InterpolationType interpolationType = Tweener.InterpolationType.LINEAR, float delay = 0f)
    {
        AnimationHandler animationHandler = new AnimationHandler();

        if (Mathf.Abs(startValue - endValue) > Tweener.MinTargetDifference)
        {
            tweeners.Add(new ValueTweener(this.gameObject, duration, startValue, onUpdate, endValue, interpolationType, delay));
            animationHandler.AddTweener(tweeners [tweeners.Count - 1]);
        }

        return(animationHandler);
    }
コード例 #6
0
ファイル: ValueTweener.cs プロジェクト: pjanek935/NeuralCars
 public ValueTweener(GameObject gameObject, float duration, float startValue, Tweener.TweenerEventHandler onUpdate,
                     float targetValue, InterpolationType tweenerInterpolationType = InterpolationType.LINEAR, float delay = 0f)
 {
     setup(gameObject, duration, targetValue, startValue, TweenerType.VALUE, interpolationType, delay);
     this.OnValueUpdate += onUpdate;
 }