|
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.
(comments are locked)
|
|
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. Thanks for the answer. Very kind of you. I love those people who care about responding. But these functions wont really satisfy my need though. What i really want is: a window to appear when I click on a game object with my left mouse button. Just One click on a creature and then a window comes up with text. I do not want to click on a GUI button on screen or a key to make this happen. I would really apreciate further help here. Thanks :} Only one click on the game object.
Nov 29 '09 at 09:49 PM
MIkhail
(comments are locked)
|
(comments are locked)
|
|
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:
(comments are locked)
|
|
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.
(comments are locked)
|
|
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: Function Start(){ Function OnMouseUp(){ Voila :P espérons que ca sera utile ^^
(comments are locked)
|
