28 lines
853 B
C#
28 lines
853 B
C#
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
|
// Script adds handler to GameObject that is interactable.
|
|
public class InteractiveHandler : MonoBehaviour, IPointerDownHandler, IPointerClickHandler
|
|
{
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
var interactiveComponent = GetComponent<InteractiveComponent>();
|
|
|
|
if (interactiveComponent == null)
|
|
{
|
|
Debug.LogError("InteractiveHandler: Interact() returned null");
|
|
return;
|
|
}
|
|
|
|
// if the object is not interactable, return
|
|
if (interactiveComponent.Interactable == null) Debug.LogError("InteractiveHandler: Interactable is null");
|
|
|
|
interactiveComponent.Interact();
|
|
}
|
|
|
|
public void OnPointerDown(PointerEventData eventData)
|
|
{
|
|
// Debug.Log("InteractiveHandler: OnPointerDown");
|
|
}
|
|
} |