- Home /
I can't click to an UI button.
Hi.
I created an UI button. It's a children of a canvas. It has an animation to make it intractable when the player dies and shows it. I have my EventSystem. By the way, the button is as I said after the enemy dies to go to the main menu, which is basically changing the scenes.
I tried to find a solution for this for like 3 days, but couldn't find anything. I have other buttons in my main menu, which work just fine. I'm stuck...
Thanks for the help.
(You can ask questions about my problem)
Edit: Screenshots:
Edit 2: Still not solved. Tried a lot of things.
Last edit: SOLVED! The problem was that my canvas had a canvas group and it was not intractable. I added a Canvas Group component and checked intractable on the ignore parent group on. So it was just that... Thank you all for trying to help me. Much appreciated.
A lot more information will be required. How do you know that the button is not being clicked, as opposed to the event bindings for the button being broken or the code in an event binding simply not working as expected?
Hi, thanks. I know that because I use the exact same code for other buttons too and they work just fine. I'm a beginner, so my button and canvas system is really not complicated, so I do not think there will be errors. By the way, its color doesn't also change when I hover my mouse on them.
So there is probably something wrong with the button (script) component. Or there is something blocking it. I really have no idea.
@bolkay nailed it. Post pictures of your scene hierarchy and the components of your button and people might be able to help you.
Ok, i've seen it and appears to be well. @redfirearne. What to do? TRY to drag the button up in the hierarchy to be just under HealthUI object. Try it quickly.
Check the answer here :
http://answers.unity3d.com/questions/1402544/so-my-buttons-stop-working.html
tried it. it doesnt show, but everything you said, are in my scene.
Answer by Positive7 · Sep 30, 2017 at 10:47 PM
In Canvas you have a Canvas Group
and interactable
is turned off. On Game Over turn it on and everything should work fine or add a Canvas Group
to the button gameObject and enable "Ignore Parent Groups"
O$$anonymous$$G! That's it! You found it. Thank you very much!... :)
Answer by FernandoGBR · Sep 30, 2017 at 05:27 PM
If I am not wrong, and you are doing what you say, there is nothing preventing the method to execute.
Have you tested with a Debug.Log() if the flow reachs the method that you are calling?
Is the main scene added to the build scenes in the build settings?
I hope my little knowledge can help you.
Yes, it is added to the build scenes. But, I don't know how to test it with a Debug.Log(). But as I saw, in the EventSystem, it doesn't say that I'm on the button.
You are supposed to be calling a public funcion inside a monobehaviour script attached to that button$$anonymous$$anager
. That function is supposed to be called openAnother...
. Try to place Debug.Log("I am inside the function");
in the first line of the function and the unity console must tell you that string.
Nope, it doesn't work. As I expected. Because I said nothing in the button works. Normal color, highlighted color, nothing.
Answer by ronzkie88 · Jan 20, 2018 at 11:44 AM
Hey Guys I had the Same issue I resolved the issue by turning on intractable like @Positive7 said but also turn on Blocks RayCasts this is what solved this issue for me. @redfirearne :) Hope it helps.,Hi Guys I had the Same Issue and after animation Turn on Intractable on as well a turning on Blocks RayCasts this worked for me as After my game over canvas animation my button was not clickable.
Hi, I've already resolved the issue by turning intractable on :)
But thanks, others might find this helpful.