63 lines
1.3 KiB
C#
63 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using NaughtyAttributes;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
public class BaseInteractable : MonoBehaviour, IInteractable
|
|
{
|
|
public UnityEvent onSelectEnterEvent;
|
|
public UnityEvent onSelectExitEvent;
|
|
public UnityEvent onHoverEnterEvent;
|
|
public UnityEvent onHoverExitEvent;
|
|
|
|
public virtual void onHoverEnter()
|
|
{
|
|
onHoverEnterEvent?.Invoke();
|
|
}
|
|
public virtual void onHoverExit()
|
|
{
|
|
onHoverExitEvent?.Invoke();
|
|
}
|
|
|
|
private void OnMouseEnter()
|
|
{
|
|
onHoverEnter();
|
|
}
|
|
private void OnMouseExit()
|
|
{
|
|
onHoverExit();
|
|
}
|
|
|
|
public virtual void onSelectEnter()
|
|
{
|
|
onSelectEnterEvent?.Invoke();
|
|
}
|
|
public virtual void onSelectExit()
|
|
{
|
|
onSelectExitEvent?.Invoke();
|
|
}
|
|
|
|
public virtual void highLightOn()
|
|
{
|
|
Outline outline = GetComponent<Outline>();
|
|
if (outline == null)
|
|
{
|
|
outline = gameObject.AddComponent<Outline>();
|
|
outline.OutlineMode = Outline.Mode.OutlineVisible;
|
|
outline.OutlineWidth = 7f;
|
|
}
|
|
}
|
|
|
|
public virtual void highLightOff()
|
|
{
|
|
if (TryGetComponent<Outline>(out Outline outline))
|
|
{
|
|
Destroy(outline);
|
|
}
|
|
}
|
|
|
|
}
|