- Home /
Interactable buttons are disabled?
Buttons in my HudCanvas are disabled despite them being intractable. I literally cannot find a single question about this, so I'm not sure if it's been asked before. I'm fairly new to Unity(just started in the last couple of months) so I'm not sure what to do here, help?
Can you elaborate? Something like showing us your Button settings, and also how exactly it is disabled? you have a click event and it doesn't execute or...?
I have the same problem with Unity 5.
I created a basic button:
And on "play" the button is immediately disabled:
EDIT: problem solved, see my other answer
I have the same problem:/ EventSystem is there, enabled and intractable set, but on start up its disabled...and no code is able to re enable it
Answer by Ensutee · Nov 24, 2015 at 10:01 AM
I just had a similar issue and spent an annoying amount of time trying to solve it.
The cause of my case was simply that a parent object had a CanvasGroup component which had "Interactable" disabled. This then rolled out into all of its children resulting in a similar case to what you were experiencing. Enabling "Interactable" solved the issue for me.
That would be: Enabling "Interactable" on the parent CanvasGroup. Alternatively you can add a new canvas group on the button object, set that to interactable and tell it to overwrite it's parent.
O$$anonymous$$G, you saved my *ss so hard, i must login to like this!!!
Answer by irilox · Apr 29, 2015 at 12:20 PM
I had the same problem and explained my problem in this thread (still needs to be approved at this point).
And a few minutes later I suddenly found the problem (and the solution):
When you create a new Canvas, it creates automatically a gameobject "EventSystem" next to it. I had deleted that one (probably by accident) and didn't remembered is was even created.
Adding a EventSystem didn't solve the problem.
To solve the problem I needed to create a new Canvas (so that is creates the EventSystem), copy the content of my old canvas to the new one and delete the old one
I hope this solves your problem
This shouldn't be the case. I just tested briefly with creating and deleting EventSystems during execution with just a Button in a Canvas, and the Button behavior worked as expected when EventSystems were added, without having to recreate the entire Canvas.
Answer by zviaz · Apr 08, 2015 at 09:19 AM
Not sure if this helps (might be your button script) but this is the StartButton.cs script I use for a "Start Game" button on the title/start screen. (I'm using Unity 5) Simply create an empty Game Object in the Canvas and attach the script.
using UnityEngine;
public class StartButton : MonoBehaviour
{
void OnGUI()
{
const int buttonWidth = 84;
const int buttonHeight = 60;
Rect buttonRect = new Rect(
Screen.width / 2 - (buttonWidth / 2),
(1 * Screen.height / 4) - (buttonHeight / 2),
buttonWidth,
buttonHeight
);
if(GUI.Button(buttonRect," PLAY "))
{
Application.LoadLevel(1);
}
}
}