summaryrefslogtreecommitdiff
path: root/GameCode/HoverEvent_WobbleButton.cs
blob: 83e60799e72595f792977dd9bcdb02285534fc1b (plain)
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
38
39
40
41
42
43
44
45
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

public class HoverEvent_WobbleButton : MonoBehaviour
{
	public float min = 1f;

	public float max = 1.1f;

	public float spring = 1f;

	public float drag = 1f;

	public float force = -0.1f;

	private ScaleShake sh;

	private void Awake()
	{
		HoverEvent hoverEvent = base.gameObject.AddComponent<HoverEvent>();
		sh = base.gameObject.AddComponent<ScaleShake>();
		Button component = GetComponent<Button>();
		sh.spring = spring;
		sh.drag = drag;
		sh.multiplier = force;
		sh.high = max;
		sh.low = min;
		sh.useTimeScale = false;
		sh.SetTarget(min);
		UnityEvent unityEvent = new UnityEvent();
		unityEvent.AddListener(sh.SetHigh);
		hoverEvent.enterEvent = unityEvent;
		UnityEvent unityEvent2 = new UnityEvent();
		unityEvent2.AddListener(sh.SetLow);
		hoverEvent.exitEvent = unityEvent2;
		component.onClick.AddListener(sh.AddForce);
	}

	private void OnDisable()
	{
		base.transform.localScale = Vector3.one * min;
		sh.SetTarget(min);
	}
}