Hi,
I would love to change button color on click but have no idea how to access the color. I see that my button has component Image which includes that color however I am unable to access it. I have the same issue with button’s text where I also didn’t found a way how to access it.
I have tried follow this tutorial but I am getting error (more on screenshots).
// I am also using this import on top if it is relevant
using UnityEngine.UIElements;
public class GameManager : MonoBehaviour {
//...
// This is my onclick function
public void SelectLevel(int level ) {
Debug.Log(level);
GameObject btn = GameObject.Find("Btn" + level);
Debug.Log(btn);
Image imgButton = btn.GetComponent<Image>();
Debug.Log(imgButton);
}
}
This is log:
This is the btn in inspector: