- Home /
How to link gui buttons to seperate scripts?
I have created a java script gui in my unity project, a tool bar with a number of buttons that acttivate different modes (eg, tour, flight, sun, build). see attached image, I already have a seperate "build" script that works when I press the tab key, but I also want this build mode to become availabe when I press the block build button seen in my attached image. how do I link the press of this button to a previously created script?!
read the very first pages of the documentation
http://docs.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Components.html
http://docs.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html
they explain it at great detail ann they explain it very well
fattie i suggest you turn your comment into an answer, cuz thats the answer
Answer by programmrzinc · Oct 05, 2012 at 05:37 PM
in the script you want to link, add the gui function. I literally mean add the part that controls GUI in script 1 into the script you need to link. Since it is a code rendered GUI, you can render it in ANY script
function OnGui(){
//your GUI Code
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613081920im_/https://answers.unity.com/themes/thub/images/avi.jpg)