android 按钮果冻效果,用Tween动画简单模拟果冻按钮效果

网上有关于果冻效果的插件JellySprites,我呢,只想要一个点击一下按钮,按钮会像果冻一样动一下。没必要弄那么复杂。我就用tween动画写了一下。写出分享给大家。

using UnityEngine;

using System.Collections;

public class JellyButton : MonoBehaviour {

Vector3 m_Scale;

void Start() {

m_Scale = transform.localScale;

}

void OnClick()

{

StartCoroutine(JellyEffect());

}

IEnumerator JellyEffect() {

TweenScale.Begin(gameObject, 0.05f, new Vector3(m_Scale.x * 1.1f, m_Scale.y * 0.8f, m_Scale.z));

yield return new WaitForSeconds(0.05f);

TweenScale.Begin(gameObject, 0.1f, new Vector3(m_Scale.x * 0.8f, m_Scale.y * 1.1f, m_Scale.z));

yield return new WaitForSeconds(0.1f);

TweenScale.Begin(gameObject, 0.1f, new Vector3(m_Scale.x * 1.07f, m_Scale.y * 0.85f, m_Scale.z));

yield return new WaitForSeconds(0.1f);

TweenScale.Begin(gameObject, 0.15f, new Vector3(m_Scale.x * 0.85f, m_Scale.y * 1.07f, m_Scale.z));

yield return new WaitForSeconds(0.15f);

TweenScale.Begin(gameObject, 0.2f, new Vector3(m_Scale.x * 1.05f, m_Scale.y * 0.9f, m_Scale.z));

yield return new WaitForSeconds(0.2f);

TweenScale.Begin(gameObject, 0.2f, new Vector3(m_Scale.x * 0.95f, m_Scale.y * 1.035f, m_Scale.z));

yield return new WaitForSeconds(0.2f);

TweenScale.Begin(gameObject, 0.25f, m_Scale);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值