基础内容
必要插件安装 缓动曲线和动画基础 ElementFolder,Track与其次级模块,PathNode重构
This commit is contained in:
50
Assets/Modern UI Pack/Scripts/Rendering/Ripple.cs
Normal file
50
Assets/Modern UI Pack/Scripts/Rendering/Ripple.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Michsky.MUIP
|
||||
{
|
||||
public class Ripple : MonoBehaviour
|
||||
{
|
||||
public bool unscaledTime = false;
|
||||
public float speed;
|
||||
public float maxSize;
|
||||
public Color startColor;
|
||||
public Color transitionColor;
|
||||
Image colorImg;
|
||||
|
||||
void Start()
|
||||
{
|
||||
transform.localScale = new Vector3(0f, 0f, 0f);
|
||||
colorImg = GetComponent<Image>();
|
||||
colorImg.raycastTarget = false;
|
||||
colorImg.color = new Color(startColor.r, startColor.g, startColor.b, startColor.a);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (unscaledTime == false)
|
||||
{
|
||||
transform.localScale = Vector3.Lerp(transform.localScale, new Vector3(maxSize, maxSize, maxSize), Time.deltaTime * speed);
|
||||
colorImg.color = Color.Lerp(colorImg.color, new Color(transitionColor.r, transitionColor.g, transitionColor.b, transitionColor.a), Time.deltaTime * speed);
|
||||
|
||||
if (transform.localScale.x >= maxSize * 0.998)
|
||||
{
|
||||
if (transform.parent.childCount == 1) { transform.parent.gameObject.SetActive(false); }
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
transform.localScale = Vector3.Lerp(transform.localScale, new Vector3(maxSize, maxSize, maxSize), Time.unscaledDeltaTime * speed);
|
||||
colorImg.color = Color.Lerp(colorImg.color, new Color(transitionColor.r, transitionColor.g, transitionColor.b, transitionColor.a), Time.unscaledDeltaTime * speed);
|
||||
|
||||
if (transform.localScale.x >= maxSize * 0.998)
|
||||
{
|
||||
if (transform.parent.childCount == 1) { transform.parent.gameObject.SetActive(false); }
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user