22 lines
717 B
C#
22 lines
717 B
C#
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.EventSystems;
|
||
|
|
|
||
|
|
// IPointerClickHandler is the magic interface that listens to ALL mouse clicks
|
||
|
|
public class JobButton : MonoBehaviour, IPointerClickHandler
|
||
|
|
{
|
||
|
|
[Tooltip("Select which job this specific button manages.")]
|
||
|
|
public NPC.Job jobType;
|
||
|
|
|
||
|
|
public void OnPointerClick(PointerEventData eventData)
|
||
|
|
{
|
||
|
|
// Intercept the click and pass the command to the UIController
|
||
|
|
if (eventData.button == PointerEventData.InputButton.Left)
|
||
|
|
{
|
||
|
|
UIController.Instance.AddJob(jobType);
|
||
|
|
}
|
||
|
|
else if (eventData.button == PointerEventData.InputButton.Right)
|
||
|
|
{
|
||
|
|
UIController.Instance.RemoveJob(jobType);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|