Custom Animations
HookUI comes with simple built-in animations (Fade, Scale, Slide). However, for professional games, you usually want to use DOTween or standard Unity Animations.
extending HookView
You can simply override the ShowRoutine and HideRoutine methods.
public class MyTweenView : HookView
{
public override IEnumerator ShowRoutine()
{
canvasGroup.alpha = 0;
// Example with DOTween (pseudo-code)
// yield return transform.DOScale(1, 0.5f).WaitForCompletion();
// Manual way:
float t = 0;
while(t < 0.5f) {
t += Time.deltaTime;
canvasGroup.alpha = t / 0.5f;
yield return null;
}
canvasGroup.alpha = 1;
}
}
Using HookAnimatorComponent
If you want reusable animations without inheriting HookView, you can create custom components that subscribe to the view's events.
[RequireComponent(typeof(HookView))]
public class ViewSoundEffect : MonoBehaviour
{
void Awake()
{
var view = GetComponent<HookView>();
view.OnShowStarted.AddListener(PlaySound);
}
void PlaySound() { ... }
}