网上有关于果冻效果的插件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));

本文介绍如何不依赖复杂插件,仅通过Tween动画实现Unity中按钮的简易果冻效果,点击按钮后,按钮会产生如同果冻般的动态反馈。
最低0.47元/天 解锁文章
2537

被折叠的 条评论
为什么被折叠?



