hey
I searched every where for it and used all of scripts… but it didn’t work. there is a trigger as you can see in scripts , I want to add a show.text order to it. I attached this script to my Trigger . what should I add?
using UnityEngine;
using System.Collections;
public class WarningArea : MonoBehaviour
{
void Update()
{
If i am understanding you right, there are different approaches.
a) Use GUI.Label to show a text:
public class WarningArea : MonoBehaviour
{
string message = "";
void OnTriggerEnter(Collider otherObjective)
{
if (otherObjective.tag == "MainCamera")
{
audio.Play();
message = "Warning text or something!";
}
}
void OnTriggerExit(Collider other)
{
message = "";
}
void OnGUI()
{
GUI.Label(new Rect(0, 0, 200, 20), message);
}
}
b) Use a TextMesh (GameObject → Create Other → 3D Text) and show it in OnCollisionEnter and hide it in OnCollisionExit
@sven1994 your code is having problems working... i attached it to a trigger and got the GUI in the trigger, but it seems to not like the code anyway... it does not know tag, MonoBehavior, rect, collider, or GUI.Label. Am I using something different? I have a cube that I selected trigger and disabled mesh filter, making it invisible and you can go through it...
@sven1994 your code is having problems working... i attached it to a trigger and got the GUI in the trigger, but it seems to not like the code anyway... it does not know tag, MonoBehavior, rect, collider, or GUI.Label. Am I using something different? I have a cube that I selected trigger and disabled mesh filter, making it invisible and you can go through it...
– Steel598