make gui text appear?

can somebody help me with a script???

the script is going to make a GUI text saying “game over” when a trigger is triggered

please help me, it is an important thing in an game I am working on

You need to think of this like a state machine. Have some variable that when set to true, triggers the drawing of your GUI text.

var ShowGameOver = false;

function OnGUI () {
  if (ShowGameOver) {
    GUI.Text(...);
  }
}

Give that a go and see what you can work up.

Tip: please post UnityGUI related questions in the UnityGUI section. Thanks! (I’ll move the thread now)

thanks a lot

but now, I need a script that doesent show the GUI if the gameobjeckt is in a special layer or a tag

I’m totaly new in unity, so I cant so many things, I spent some hours to try to find a way, but all I got was errors

FYI, folks aren’t here to write scripts for you so I won’t gift that one. Give a man a fish, feed him for a day; teach a man to fish, feed him for a lifetime… :wink: :slight_smile:

I’ve shown you the basics, you have a boolean that when true shows something, when false it doesn’t. Where are you stuck in this second issue? Do you know how to determine the layer/tag of a game object? Do you know how to use that to toggle a boolean value on/off? You said you tried but only produced errors, what was the code you tried?

well

I don’t even know what boolean vallue means

and I have tried to use diffrent kinds of scripts so the scripts that is producing errors is deleted but the newest script is keep saying that it has to compile, the only problem is that it has been compiling in 12 hours

heres the script

using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}

void OnTriggerEnter (){

if (gameObject.tag == 0) {
GUI.Box (Rect (10,10,100,90), "Loader Menu");

	// Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
	if (GUI.Button (Rect (20,40,80,20), "Level 1")) {
		Application.LoadLevel (1);
		}
	}		
}

}

I don’t know if it is a javascript or c#, after a while, I didnt know what I was writing at all

can someone please tell me what I did wrong

Then please, sit down and do a basic introductory tutorial on scripting in general. Booleans are a very basic and simple data type (true/false) that are fundamental to the scripting experience (along with strings, integers and floating point values among others). Saying that you don’t know what a boolean is clearly shows that fundamentals are needed before you wander much further into this GUI stuff

I’m sorry but it sounds as if you’re just doing a bit of blind bashing about, especially if you’re not familiar with scripting at all.

That is C# and there are errors. For instance, as per the documentation about the tag property, tags are strings and will never be equal to zero (an integer) as you’re checking for, so swap that to be a string comparison (like == “0” or == “Foo” or ???). Also, in C# you must use ‘new Rect(…)’ not just ‘Rect(…)’, FWIW JavaScript lets you be lazy and drop the ‘new’. :slight_smile:

But seriously, look around for some simple “welcome to scripting tutorials” to learn some basics. There is a simple and short Scripting Tutorial installed with Unity (look in the app folder), check the Unify Community Wiki or the following tutorial sites:

http://vimeo.com/channels/ncsuunity
http://vimeo.com/ryanzec
http://unitytutorials.com/
http://unity-tutorials.com/
http://diamondtearz.org/lists/unity3d-scripting/

And last but not least, look at buying Will Goldstone’s book about Unity:

Oh, and have fun while learning as Unity will reward your effort ten-fold! :smile:

Ok, thanks