-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInteraction.cs
More file actions
52 lines (46 loc) · 1.44 KB
/
Interaction.cs
File metadata and controls
52 lines (46 loc) · 1.44 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using System;
using Lean.Touch;
[RequireComponent(typeof(LeanSelectable))]
public class Interaction : MonoBehaviour
{
[Tooltip("This event is called when you click on this object if it has been focussed by the camera, Unless it has no POI component then it is always called when you click on the object.")]
public UnityEvent InteractEvent;
private LeanSelectable leanSelectable;
public void Interact(LeanFinger leanFinger)
{
if (TryGetComponent(out PointOfInterest pointOfInterest))
{
if (pointOfInterest.IsFocused)
{
InteractEvent.Invoke();
//Debug.Log("Invoked interact event (Focussed on POI");
}
}
else
{
InteractEvent.Invoke();
//Debug.Log("Invoked interact event (No POI)");
}
}
private void OnEnable()
{
leanSelectable.OnSelectUp.AddListener(Interact);
}
private void OnDisable()
{
leanSelectable.OnSelectUp.RemoveListener(Interact);
}
private void Awake()
{
leanSelectable = GetComponent<LeanSelectable>();
}
//temp example
public void SimpleFall(Transform fallingObject)
{
LeanTween.rotateX(fallingObject.gameObject, 85, 0.5f).setEaseOutBounce();
}
}