I have a simple class attached to a button in Unity Canvas:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
public class AudioButtonPlay : MonoBehaviour
{
public Button button;
void Start()
{
button = gameObject.GetComponent<Button>();
}
}
But on the line button = gameObject.GetComponent<Button>(); I get the following message:
GetComponent requires that the requested component 'Button' derives from MonoBehaviour or Component or is an interface
How can I access the "Button" component?