How would I do that? If you don’t understand, I want a GUI Texture to pop up on the screen when something is triggered(which I know how to do). Any ideas?
Consider using boolean variables.
var displayMessage : boolean = false;
function Update(){
if(Input.GetKeyDown("space"))
displayMessage=!displayMessage;
}
function OnGUI () {
if (displayMessage)
GUI.Label (Rect (10, 10, 100, 20), "Hello World!");
}
The event would be, I pressed the space bar, the result is… it displays a message. This can be done with any GUI object… So a GUITexture
A GUITexture is a Unity object, not part of OnGUI.
In any case, you instantiate a GUITexture the same as any other prefab.
var guiTex : GUITexture;
function OnTriggerEnter () {
Instantiate (guiTex);
}
–Eric
That’s basicaly what I want to do, but how can I change the location?
Instantiate(guiTex,position,rotation) then just specify what your position needs to be
Ok I tried this, and it completely failed:
var guiTexture : Transform;
function OnCollisionEnter(collision : Collision){
if(collision.gameObject.tag == "ball"){
Instantiate(guiTexure, (0.5, 0.5, 0), (0, 0, 0));}}
Sorry if this looks like a completely useless attempt, but I’m not a programmer. Help? Please?
var guiTexture : Transform;
function OnCollisionEnter(collision : Collision)
{
if(collision.gameObject.tag == "ball")
{
Instantiate(guiTexure, vector3, vector3);
}
}
Fixed
It might help you
Instantiate(guiTexture, Vector3(0.5, 0.5, 0), Quaternion.identity );
And I think that your guiTexture isn’t “Transform” type but “GUITexture”.
Well, I have a prefab, which is a GUITexture with a script on it. What should I do then?
I noticed you were trying to instantiate guiTexure with the last “t” missing.
If you are only ever going to instantiate at Vector3(0.5, 0.5, 0), then incorporate that position into the prefab and then you can just use Instantiate(guiTexture)
Oh, my fault. Fixed it.