I’d like to be able to animate my button upon different events like press, release etc. But I’d prefer not to use Mecanim and instead tween the buttons myself using DOTween. Is there a way I can do this?
you need the Unity Pointhandlers:
using UnityEngine;
using UnityEngine.EventSystems;
public class *yourScriptName*: MonoBehaviour, IPointerEnterHandler ,IPointerExitHandler{
// Mouse gets into UI-Box
public void OnPointerEnter(PointerEventData data) {
StartCoroutine(Animate(true));
}
//Mouse gets outside UI-Box
public void OnPointerExit(PointerEventData data) {
StartCoroutine(Animate(false));
}
private IEnumerator Animate(bool hover) {
if (hover == true) {
//Animate in
}else {
//Animate Out
}
yield break;
}
}