- Home /
Gui.Button over Gui.TextArea does not work. Why?
I place a Gui.Button over a Gui.Textarea. And if i try to click it it always selects the Gui.Textarea under it.
Is there a way to solve this problem?
Answer by Mike 3 · Jun 27, 2010 at 09:56 PM
(really) hacky way to fix it quickly:
GUI.Button(blah);
GUI.TextArea(other blah);
GUI.Button(blah);
It uses the first button for input, the second to get drawn on top of the text box
The alternative is to handle the event catching yourself before the text box, use the event if it hits the button's position, and then call your if function and change the style of the button to make it look active
I managed it another way. draw a box for the background. and a smaller textarea above the box. So, where the button is there is no textarea anymore. But thanks for the hack. ;)
Sounds good - overlapping controls do sound like a bad idea ;)
Answer by Tetrad · Jun 27, 2010 at 05:49 PM
If your Button is in a separate OnGUI
function, you could try playing around with GUI.depth
. If it isn't, maybe you could try reordering which gets rendered first. You probably want the button after the textarea.
It is in the same Gui call, and how my Gui $$anonymous$$enu works, it would be not nice to put it outside of this. And the Button is called after the textfield. Becouse my textfield has a solid color background and if i wouldnt do it, i wouldnt see it. But the realy strange thing is, if it is behind the textfield, the button works fine. :/
GUI.depth solved all my GUI.button/input conflicts, thank-you!!
Your answer
![](https://koobas.hobune.stream/wayback/20220613063202im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Problem with GUI.Button and other GUI items 1 Answer
Opening a second gui 1 Answer
Button Turns Off and On Object 1 Answer
GUI Button and a gameObject's position 3 Answers
How to hook up the particle system to jump animation? 1 Answer