I’ve looked everywhere, but I still can’t get this button to work. My button is a child of a Canvas object and there is an EventSystem in the hierarchy. This thread seems the most similar to my issue:
Unfortunately, his solution did not work for me. My button is already the highest element in the Canvas. Here is a screenshot:
Turn the “Raycast Target” boolean on the Image script to true. It’s currently set to false. This should solve your problem.
Otherwise, you have the button animated. When you hover over it with your mouse, does it animate accordingly?
If it animates properly that means it’s interactable. The only other thing I can think of is to call an empty game object the name of your script, and then reference that object when calling the function from the button script, instead of using the canvas parent. Who knows if that’s causing an issue, but I’m pretty sure you just need to check raycast target.
Also, idk if you’re missing an assembly reference because I don’t write in C#. So try doing this same thing with a javascript file, and see if you get different results.
//js
function LoadScene(level : int){
print("Button Clicked");
Application.LoadLevel(level);
}
Again, fundamentally make sure your button is animating right in the first place. If you happen to be missing an assembly reference, you’ll need to write “using ___________;” at the top. But like I said, I’m not familiar with C#'s set up.