First commit for private source control. Older commits available on Github.
This commit is contained in:
32
Assets/Plugins/PrimeTween/Demo/Scripts/Pro/OnClick.cs
Normal file
32
Assets/Plugins/PrimeTween/Demo/Scripts/Pro/OnClick.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace PrimeTweenDemo {
|
||||
// p0 todo replace with AnimateOnClick and serialize TweenAnimation instead? no, because I need to reference all animations from one place to animate them all
|
||||
// p0 todo create Demo Pro. With which version of Unity?
|
||||
public class OnClick : MonoBehaviour {
|
||||
[SerializeField] public UnityEvent onClick = new UnityEvent();
|
||||
|
||||
void Update() {
|
||||
if (InputController.GetDown()) {
|
||||
Vector2 screenPos = InputController.screenPosition;
|
||||
var ray = Camera.main.ScreenPointToRay(screenPos);
|
||||
if (Physics.Raycast(ray, out var hit) && IsChild(hit.transform, transform)) {
|
||||
// Debug.Log("onClick", this);
|
||||
onClick.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsChild(Transform t, Transform other) {
|
||||
Transform parent = t.parent;
|
||||
while (parent != null) {
|
||||
if (parent == other) {
|
||||
return true;
|
||||
}
|
||||
parent = parent.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user