A bunch of stuff
This commit is contained in:
@@ -3,34 +3,41 @@ using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
[RequireComponent(typeof(OutlineFx.OutlineFx))]
|
||||
public class MyButton : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
[SerializeField]
|
||||
private UnityEvent _onClick;
|
||||
|
||||
|
||||
|
||||
// references
|
||||
[SerializeField]
|
||||
private OutlineFx.OutlineFx _outlineFx;
|
||||
|
||||
|
||||
[SerializeField]
|
||||
public bool isActive = true;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!TryGetComponent(out Collider2D _))
|
||||
{
|
||||
Debug.LogError("MyButton needs a Collider2D to work", gameObject);
|
||||
}
|
||||
|
||||
_outlineFx = GetComponent<OutlineFx.OutlineFx>();
|
||||
|
||||
if (!_outlineFx)
|
||||
{
|
||||
_outlineFx = GetComponent<OutlineFx.OutlineFx>();
|
||||
}
|
||||
_outlineFx.enabled = false;
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
_onClick.Invoke();
|
||||
if(isActive)
|
||||
_onClick.Invoke();
|
||||
}
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
_outlineFx.enabled = true;
|
||||
_outlineFx.enabled = isActive;
|
||||
}
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user