- Home /
My button is dead forever even though the interactable is checked. Bug in Unity?
The button is just frozen and I think its because of a function I attached to the script but what even when I reset the Button component on that button it is still frozen. I am calling it frozen because unlike other buttons it is not dimming when I click and hold on it and also it is not working even though I attach a good working function to the OnClick event. It is still dead and the only round about is delete the button and recreate it ,but again when I attach the previously told function and run it again it works once but the next time (sometimes it is working for a couple of times),it is dead again and forever no matter what ever I reset in that button.
I actually think this is a bug in unity... please confirm.
And ya the code is here...
public void SaveState()
{
newGame.GetComponent<Canvas> ().enabled = !newGameState;
newGameState = !newGameState;
characterCreation.GetComponent<Canvas> ().enabled = !characterCreationState;
characterCreationState = !characterCreationState;
headCust.GetComponent<Canvas> ().enabled = !headCustState;
headCustState = !headCustState;
hairCust.GetComponent<Canvas> ().enabled = !hairCustState;
hairCustState = !hairCustState;
eyesCust.GetComponent<Canvas> ().enabled = !eyesCustState;
eyesCustState = !eyesCustState;
nextAndBackBtn.GetComponent<Canvas> ().enabled = !nextAndBackBtnState;
nextAndBackBtnState = !nextAndBackBtnState;
}
Savestate is the function I attached to the button.
newGame,characterCreation,headCust,hairCust,eyesCust,nextAndBackBtn are all just canvases which I am enabling and disabling the canvas component(this method is working for other buttons which I have coded in a same way)
I am using unity4.6 not the beta but the stable version.
Answer by Mmmpies · Dec 28, 2014 at 10:50 AM
The new UI is good but as panels and other objects can be invisible but still block raycasts it can hide a button behind another transparent panel.
Move the button to the bottom of the list of UI elements if possible, the order of UI is top == back bottom == front so moving the button down should move it in front of the other objects.
If that fixes it you probably still need to work out which panel or text or really any UI element was causing the issue.
I deleted all my child canvases and replaced them with panels and now it is working :)
That's O$$anonymous$$ @Vickylance thanks for getting back to me and thanks @jakovd