コード例 #1
0
ファイル: Demo.cs プロジェクト: Zoaxx1/PacmanGame
    void Start()
    {
        //DEMO 2 - MODIFIERS
        linear1Animation     = UIAnimator.MoveHorizontal(modDemo1, 0.3f, 0.7f, 2f);
        linear2Animation     = UIAnimator.MoveHorizontal(modDemo2, 0.3f, 0.7f, 2f).SetModifier(Modifier.Linear);
        quadInAnimation      = UIAnimator.MoveHorizontal(modDemo1, 0.3f, 0.7f, 2f).SetModifier(Modifier.QuadIn);
        quadOutAnimation     = UIAnimator.MoveHorizontal(modDemo2, 0.3f, 0.7f, 2f).SetModifier(Modifier.QuadOut);
        cubInAnimation       = UIAnimator.MoveHorizontal(modDemo1, 0.3f, 0.7f, 2f).SetModifier(Modifier.CubIn);
        cubOutAnimation      = UIAnimator.MoveHorizontal(modDemo2, 0.3f, 0.7f, 2f).SetModifier(Modifier.CubOut);
        polyInAnimation      = UIAnimator.MoveHorizontal(modDemo1, 0.3f, 0.7f, 2f).SetModifier(Modifier.PolyIn);
        polyOutAnimation     = UIAnimator.MoveHorizontal(modDemo2, 0.3f, 0.7f, 2f).SetModifier(Modifier.PolyOut);
        sinAnimation         = UIAnimator.MoveHorizontal(modDemo1, 0.3f, 0.7f, 2f).SetModifier(Modifier.Sin);
        tanAnimation         = UIAnimator.MoveHorizontal(modDemo2, 0.3f, 0.7f, 2f).SetModifier(Modifier.Tan);
        circularInAnimation  = UIAnimator.MoveHorizontal(modDemo1, 0.3f, 0.7f, 2f).SetModifier(Modifier.CircularIn);
        circularOutAnimation = UIAnimator.MoveHorizontal(modDemo2, 0.3f, 0.7f, 2f).SetModifier(Modifier.CircularOut);
        //DEMO 3 - EFFECTS
        springEffect1    = UIAnimator.Move(effDemo1, new Vector2(0.5f, 0.7f), new Vector2(0.8f, 0.7f), 2f).SetModifier(Modifier.PolyIn).SetEffect(Effect.Spring(0.21f, 4));
        springEffect2    = UIAnimator.Move(effDemo2, new Vector2(0.5f, 0.5f), new Vector2(0.8f, 0.5f), 2f).SetEffect(Effect.Spring(0.2f, 6), Quaternion.Euler(0, 0, 90f));
        springEffect3    = UIAnimator.Move(effDemo3, new Vector2(0.2f, 0.6f), new Vector2(0.2f, 0.6f), 2f).SetEffect(Effect.Spring(0.1f, 4));
        springEffect4    = UIAnimator.Move(effDemo4, new Vector2(0.4f, 0.6f), new Vector2(0.4f, 0.6f), 2f).SetEffect(Effect.Spring(0.1f, 4), Quaternion.Euler(0, 0, 90f));
        waveEffect1      = UIAnimator.Move(effDemo1, new Vector2(0.5f, 0.7f), new Vector2(0.8f, 0.7f), 2f).SetModifier(Modifier.CircularIn).SetEffect(Effect.Wave(0.05f, 10));
        waveEffect2      = UIAnimator.Move(effDemo2, new Vector2(0.5f, 0.5f), new Vector2(0.8f, 0.5f), 2f).SetModifier(Modifier.Linear).SetEffect(Effect.Wave(0.1f, 6), Quaternion.Euler(0, 0, 90f));
        waveEffect3      = UIAnimator.Move(effDemo3, new Vector2(0.2f, 0.6f), new Vector2(0.2f, 0.6f), 2f).SetEffect(Effect.Wave(0.1f, 4));
        waveEffect4      = UIAnimator.Move(effDemo4, new Vector2(0.4f, 0.6f), new Vector2(0.4f, 0.6f), 2f).SetEffect(Effect.Wave(0.1f, 4), Quaternion.Euler(0, 0, 90f));
        explosionEffect1 = UIAnimator.Move(effDemo1, new Vector2(0.5f, 0.7f), new Vector2(0.8f, 0.7f), 2f).SetModifier(Modifier.CircularOut);
        explosionEffect2 = UIAnimator.Move(effDemo2, new Vector2(0.5f, 0.5f), new Vector2(0.8f, 0.5f), 2f).SetModifier(Modifier.CircularOut).SetEffect(Effect.Explosion(0.2f));
        explosionEffect3 = UIAnimator.Move(effDemo3, new Vector2(0.2f, 0.6f), new Vector2(0.2f, 0.6f), 2f).SetEffect(Effect.Explosion(0.1f));
        explosionEffect4 = UIAnimator.Move(effDemo4, new Vector2(0.4f, 0.6f), new Vector2(0.4f, 0.6f), 2f).SetEffect(Effect.Explosion(0.2f));
        //DEMO 4 - GROUPS
        springGroupEffect = new UIGroupAnimation(
            UIAnimator.Move(groupEffDemo[0], new Vector2(0.3f, 0.6f), new Vector2(0.3f, 0.6f), 1f).SetEffect(Effect.Spring(0.2f, 4), Quaternion.Euler(0, 0, 000f)),
            UIAnimator.Move(groupEffDemo[1], new Vector2(0.3f, 0.6f), new Vector2(0.3f, 0.6f), 1f).SetEffect(Effect.Spring(0.2f, 4), Quaternion.Euler(0, 0, 090f)),
            UIAnimator.Move(groupEffDemo[2], new Vector2(0.3f, 0.6f), new Vector2(0.3f, 0.6f), 1f).SetEffect(Effect.Spring(0.2f, 4), Quaternion.Euler(0, 0, 180f)),
            UIAnimator.Move(groupEffDemo[3], new Vector2(0.3f, 0.6f), new Vector2(0.3f, 0.6f), 1f).SetEffect(Effect.Spring(0.2f, 4), Quaternion.Euler(0, 0, 270f))
            );
        waveGroupEffect = new UIGroupAnimation(
            UIAnimator.Move(groupEffDemo[0], new Vector2(0.3f, 0.6f), new Vector2(0.3f, 0.6f), 4f).SetEffect(Effect.Wave(0.2f, 4), Quaternion.Euler(0, 0, 090f)),
            UIAnimator.Move(groupEffDemo[1], new Vector2(0.3f, 0.6f), new Vector2(0.3f, 0.6f), 4f).SetEffect(Effect.Wave(0.2f, 4), Quaternion.Euler(0, 0, 045f)).SetDelay(0.25f),
            UIAnimator.Move(groupEffDemo[2], new Vector2(0.3f, 0.6f), new Vector2(0.3f, 0.6f), 4f).SetEffect(Effect.Wave(0.2f, 4), Quaternion.Euler(0, 0, 000f)).SetDelay(0.50f),
            UIAnimator.Move(groupEffDemo[3], new Vector2(0.3f, 0.6f), new Vector2(0.3f, 0.6f), 4f).SetEffect(Effect.Wave(0.2f, 4), Quaternion.Euler(0, 0, 315f)).SetDelay(0.75f)
            );
        explosionGroupEffect = new UIGroupAnimation(groupEffDemo, UIAnimator.Move(groupEffDemo[0], new Vector2(0.3f, 0.6f), new Vector2(0.7f, 0.6f), 2f));
        //DEMO 5 = SCALE/ROTATE
        scale1Animation    = UIAnimator.Scale(scaleDemo1, new Vector3(0.0f, 0.0f), new Vector3(2.5f, 2.5f), 2f).SetModifier(Modifier.PolyIn).SetEffect(Effect.Wave(0.2f, 7));
        rotation1Animation = UIAnimator.Rotate(scaleDemo2, Quaternion.Euler(0, 0, -90), Quaternion.Euler(0, 0, 90), 2f);
        //DEMO 6 - COLOR
        callback1Animation = UIAnimator.Move(colorDemo[0].rectTransform, new Vector2(0.3f, 0.45f), new Vector2(0.3f, 0.75f), 1f);
        callback2Animation = UIAnimator.Move(colorDemo[1].rectTransform, new Vector2(0.3f, 0.75f), new Vector2(0.4f, 0.55f), 1f);
        callback3Animation = UIAnimator.Move(colorDemo[2].rectTransform, new Vector2(0.4f, 0.55f), new Vector2(0.5f, 0.75f), 1f);
        callback4Animation = UIAnimator.Move(colorDemo[2].rectTransform, new Vector2(0.5f, 0.75f), new Vector2(0.6f, 0.55f), 1f);
        callback5Animation = UIAnimator.Move(colorDemo[3].rectTransform, new Vector2(0.6f, 0.55f), new Vector2(0.7f, 0.75f), 1f);
        callback6Animation = UIAnimator.Move(colorDemo[4].rectTransform, new Vector2(0.7f, 0.75f), new Vector2(0.3f, 0.45f), 1f).SetEffect(Effect.Wave(0.2f, 1), Quaternion.Euler(0, 0, 90f));
        callback1Animation.SetCallback(callback2Animation.Play);
        callback2Animation.SetCallback(callback3Animation.Play);
        callback3Animation.SetCallback(callback4Animation.Play);
        callback4Animation.SetCallback(callback5Animation.Play);
        callback5Animation.SetCallback(callback6Animation.Play);
        callback6Animation.SetCallback(ResetAnimation);

        callback1Animation.Play();
        //DEMO 7 - LOOP
        //PLEASE SEE THE COMPONENTS IN INSPECTOR OR READ THE INSTRUCTIONS
    }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        if (Application.isPlaying && uiAnimation != null)
        {
            return;
        }

        rect = GetComponent <RectTransform>();
        if (rect == null)
        {
            Debug.Log("Please add a RectTransform to this object:" + gameObject.name);
            return;
        }

        List <UIAnimation> animations = new List <UIAnimation>();

        if (moveAnimation)
        {
            UpdateBehaviour     mod = EasyUIAnimatorUtils.GetModifier(moveModifier);
            Effect.EffectUpdate eff = EasyUIAnimatorUtils.GetEffect(moveEffect, max[0], bounce[0]);
            effectRotation = (randomDirection) ? Vector3.forward * Random.Range(0, 360) : effectRotation;
            Vector2 startValue = (useScreenValues) ? Vector3.Scale(start[0], (Vector3)UIAnimator.InvertedScreenDimension) : start[0];
            Vector2 finalValue = (useScreenValues) ? Vector3.Scale(final[0], (Vector3)UIAnimator.InvertedScreenDimension) : final[0];
            if (isBezier)
            {
                if (isCubicBezier)
                {
                    animations.Add(UIAnimator.MoveBezier(rect, startValue, finalValue, bezierP1, bezierP2, duration).SetModifier(mod));
                }
                else
                {
                    animations.Add(UIAnimator.MoveBezier(rect, startValue, finalValue, bezierP1, duration).SetModifier(mod));
                }
            }
            else
            {
                animations.Add(UIAnimator.Move(rect, startValue, finalValue, duration).SetModifier(mod).SetEffect(eff, Quaternion.Euler(effectRotation)));
            }
        }
        if (scaleAnimation)
        {
            UpdateBehaviour     mod = EasyUIAnimatorUtils.GetModifier(scaleModifier);
            Effect.EffectUpdate eff = EasyUIAnimatorUtils.GetEffect(scaleEffect, max[1], bounce[1]);
            animations.Add(UIAnimator.Scale(rect, start[1], final[1], duration).SetModifier(mod).SetEffect(eff));
        }
        if (rotationAnimation)
        {
            UpdateBehaviour     mod = EasyUIAnimatorUtils.GetModifier(rotationModifier);
            Effect.EffectUpdate eff = EasyUIAnimatorUtils.GetEffect(rotationEffect, max[2], bounce[2]);
            if (start[2].x != 0 || start[2].y != 0 || final[2].x != 0 || final[2].y != 0)
            {
                animations.Add(UIAnimator.Rotate(rect, Quaternion.Euler(start[2]), Quaternion.Euler(final[2]), duration).SetModifier(mod).SetEffect(eff));
            }
            else
            {
                animations.Add(UIAnimator.Rotate(rect, start[2].z, final[2].z, duration).SetModifier(mod).SetEffect(eff));
            }
        }
        if (graphicAnimation)
        {
            UpdateBehaviour mod = EasyUIAnimatorUtils.GetModifier(graphicModifier);
            image = GetComponent <Graphic>();
            if (!image)
            {
                Debug.LogError("Please attach an Image/Text component to the gameObject");
            }
            else
            {
                animations.Add(UIAnimator.ChangeColor(image, startColor, finalColor, duration).SetDelay(delay).SetModifier(mod));
            }
        }

        if (animations.Count == 0)
        {
            Debug.Log("No animation");
            return;
        }
        else
        {
            uiAnimation = new UIGroupAnimation(animations.ToArray()).SetDelay(delay);
        }

        switch (loop)
        {
        case Loop.LOOP:
            uiAnimation.SetLoop();
            break;

        case Loop.PING_PONG:
            uiAnimation.SetLoop(true);
            break;
        }

        if (playAudioOnPlay)
        {
            audioSource = GetComponent <AudioSource>();
            if (audioSource == null)
            {
                Debug.LogError("No audio source found!");
            }
        }

        if (disableAfter)
        {
            uiAnimation.SetCallback(() => { gameObject.SetActive(false); });
        }
        if (Application.isPlaying)
        {
            if (playOnStart)
            {
                Play();
            }
        }
    }
コード例 #3
0
    void Start()
    {
        if (Application.isPlaying && uiAnimation != null)
        {
            return;
        }

        rect = GetComponent <RectTransform>();
        UpdateBehaviour mMod = EasyUIAnimatorUtils.GetModifier(mod);

        Effect.EffectUpdate mEff = EasyUIAnimatorUtils.GetEffect(effect, max, bounce);
        effectRotation = (randomDirection) ? Vector3.forward * Random.Range(0, 360) : effectRotation;
        switch (animType)
        {
        case AnimationType.MOVE:
            if (useScreenValues)
            {
                uiAnimation = UIAnimator.Move(rect, Vector3.Scale(startV3, (Vector3)UIAnimator.InvertedScreenDimension), Vector3.Scale(finalV3, (Vector3)UIAnimator.InvertedScreenDimension), duration).SetDelay(delay).SetModifier(mMod).SetEffect(mEff, Quaternion.Euler(effectRotation));
            }
            else
            {
                uiAnimation = UIAnimator.Move(rect, startV3, finalV3, duration).SetDelay(delay).SetModifier(mMod).SetEffect(mEff, Quaternion.Euler(effectRotation));
            }
            break;

        case AnimationType.SCALE:
            uiAnimation = UIAnimator.Scale(rect, startV3, finalV3, duration).SetDelay(delay).SetModifier(mMod).SetEffect(mEff, Quaternion.Euler(effectRotation));
            break;

        case AnimationType.ROTATION:
            if (startV3.x != 0 || startV3.y != 0 || finalV3.x != 0 || finalV3.y != 0)
            {
                uiAnimation = UIAnimator.Rotate(rect, Quaternion.Euler(startV3), Quaternion.Euler(finalV3), duration).SetDelay(delay).SetModifier(mMod).SetEffect(mEff, Quaternion.Euler(effectRotation));
            }
            else
            {
                uiAnimation = UIAnimator.Rotate(rect, startV3.z, finalV3.z, duration).SetDelay(delay).SetModifier(mMod).SetEffect(mEff, Quaternion.Euler(effectRotation));
            }
            break;

        case AnimationType.IMAGE:
            image = GetComponent <Graphic>();
            if (!image)
            {
                Debug.LogError("Please attach an Image component to the gameObject");
                uiAnimation = null;
                return;
            }
            uiAnimation = UIAnimator.ChangeColor(image, startColor, finalColor, duration).SetDelay(delay).SetModifier(mMod);
            break;

        case AnimationType.GROUP:
            UIAnimation[] uiAnimations = new UIAnimation[fixedAnimations.Length];
            for (int i = 0; i < uiAnimations.Length; i++)
            {
                uiAnimations[i] = fixedAnimations[i].uiAnimation;
            }
            uiAnimation = new UIGroupAnimation(uiAnimations);
            break;

        default:
            break;
        }
        switch (loop)
        {
        case Loop.LOOP:
            uiAnimation.SetLoop();
            break;

        case Loop.PING_PONG:
            uiAnimation.SetLoop(true);
            break;
        }

        if (disableAfter)
        {
            uiAnimation.SetCallback(() => { gameObject.SetActive(false); });
        }
        if (Application.isPlaying)
        {
            if (playOnStart)
            {
                Play();
            }
        }
    }