I was hoping a request for help wouldn’t be my first post, but here we are. I’m trying to set a bool to true when a UI Button (LButton) is held down, but the code I am using is leading to console errors. I’ve tried to use other forum posts and Unity documentation to fix it, but I keep running into error CS0246.
Here’s my code:
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class LButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
public bool LButtonPressed;
public void OnPointerDown(PointerEventData pointerEventData)
{
LButtonDown = true;
}
public void OnPointerUp(PointerEventData pointerEventData)
{
LButtonDown = false;
}
}
I’m sorry if it’s terrible code; I only started using Unity around a week ago, and I don’t have much programming experience in other languages.