Cannot click 4.6 GUI when attached to a Game object
Using the 4.6 GUI I am unable to click any of the buttons under the red square.
I have been using the old GUI system for the longest time, i had decided to try and use the newer 4.6 GUI to perform this task. I started out with a canvas component attached to the square that draws the 4 buttons underneath the sprite and on runtime, it won't click.
After I noticed that wasn't working, I also tried to remove the canvas component, and go with a canvas and event system separate from the game object in question. when I run the game, it still won't click. Is there anything that I am missing in this?
Also, i am running Unity 5.1.1f1 if that makes a difference.
Thanks in advance everyone.
Hard to tell without seeing your hierarchy setup and components for the go with the button on it. There's some pretty quick tutorials on how to use the new GUI system.
The images below show how the hierarchy and components are set up. The piece script only snaps the piece to the grid, and then sets the inactive buttons to active.
I have tried to attach the canvas component to the object, and I have tried it without the component with the same result. I've tried it with the canvas and event system on its own, and without them at all. Also same result. Any ideas would be greatly appreciated.
Answer by Naphier · May 15, 2016 at 05:36 PM
I fear you're not using the GUI system as intended.
Add canvas
Add GUI objects as children to that canvas
With GUI Buttons add events to On Click.
A rigidbody on a canvas may interfere with that canvas. I'm not certain, I've never tried because it doesn't make a lot of sense to have a canvas with a rigidbody, Also note that the GUI has image objects.
Again, I'd highly suggest checking out the tutorials. It looks like you're making a board game. They have a full tutorial on making a tic-tac-toe game using only UI which may be of great help to you:
Your answer
Follow this Question
Related Questions
How would I select GameObjects from an array one by one? 1 Answer
Car Rotation when pressing buttons 0 Answers
How do I get an object to turn in the direction another object is facing? 0 Answers
If Mouse cursor is above an object, start animation (without click on It) 2 Answers
How to make multiple buttons 0 Answers