45 lines
832 B
C#
45 lines
832 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
public class InteractableObject : MonoBehaviour
|
|
{
|
|
[SerializeField] private InteractableView interactableView;
|
|
|
|
bool enableInteract = true;
|
|
|
|
|
|
private void Start()
|
|
{
|
|
enableInteract = true;
|
|
}
|
|
|
|
|
|
protected virtual void OnTriggerEnter2D(Collider2D collision)
|
|
{
|
|
if (!enableInteract) return;
|
|
interactableView.ShowScreen();
|
|
}
|
|
|
|
protected virtual void OnTriggerExit2D(Collider2D collision)
|
|
{
|
|
interactableView.HideScreen();
|
|
//DisableInteract();
|
|
}
|
|
|
|
|
|
public void DisableInteract()
|
|
{
|
|
enableInteract = false;
|
|
Invoke(nameof(EnableInteract), 0.1f);
|
|
|
|
}
|
|
|
|
public void EnableInteract()
|
|
{
|
|
enableInteract = true;
|
|
}
|
|
|
|
}
|