-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSlideWithPointer.cs
More file actions
37 lines (32 loc) · 1.08 KB
/
SlideWithPointer.cs
File metadata and controls
37 lines (32 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* Author: Matuyuhi
* Date: 2023-07-26
* File: SlideWithPointer.cs
*/
using AnimationPro.RunTime;
using UnityEngine;
using UnityEngine.EventSystems;
namespace AnimationPro.Component
{
[RequireComponent(typeof(RectTransform)), AddComponentMenu("AnimationPro/UI/SlideWithPointer")]
public class SlideWithPointer : SwitchableAnimationBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public override ContentTransform EnterTransform { get; set; }
public override ContentTransform ExitTransform { get; set; }
[SerializeField] private Vector2 distance = new(50f, 0f);
[SerializeField] private float delaySec = 0.3f;
private void Start()
{
EnterTransform = this.SlideTo(distance, Easings.QuartOut(delaySec));
ExitTransform = this.SlideFrom(distance, Easings.QuartIn(delaySec));
}
public void OnPointerEnter(PointerEventData eventData)
{
State = true;
}
public void OnPointerExit(PointerEventData eventData)
{
State = false;
}
}
}