How can I call up a GUI interface when i click an object?
I have some clues: Use on mouseover or onmousedown, or use collision triggers that make the GUI appear, I just cant make it to work.. Please help would be apreciated. Im new to this.
I really want to be able to controll when a GUI appears on my screen.
One way of doing it would be to have a selection manager class which keeps track of the currently selected object.
Each selectable object would then have to have a collider and a monobehaviour attached which on mouse down changes selection. By using MonoBehaviour.OnMouseDown, you don't need to worry about raycasting or GUI input clickthrough - that is taken care of for you out of the box.
To handle objects of a dynamic nature, we also need to make sure that if the currently selected object leaves the active scene by being disabled or destroyed, we tell the manager to deselect it.
Heres one example of a simple implementation:
answered Dec 03 '09 at 10:14 AM
This may be what you were looking for, if you're still here looking. :) Take this script file, drag/drop it onto an Object (say, a Cube). When you click the Cube in-game, a Button will appear with whatever text you assign it.
Note that you would have to attach this script to every Object you wanted to be clickable. This is a single-purpose solution, where some of the other Answers were showing you how to do a more general-purpose utility GUI function.
answered Mar 18 '10 at 06:38 PM
answered Nov 29 '09 at 10:34 PM
Pour ma part jai tester ce donc vous parlez...
Jai mis un cube transparent avec collission Ontrigger sur le cube, et je lai mis sur le personnage ( moob)
Sur le cube transparent jai mic ce code JS
var Moob1 : GameObject; var Fenetre1 : GUITexture:
Voila :P espérons que ca sera utile ^^
Well do you want it to happen when you press a key or click a button
for a button the basic script would be
For a key press it would be like this
That would be the basic script, you just have to modify it to your needs, hope this helps.