How do i make a 2D texture Pops up when a player went through the collider?

Yeah, i am super-duper new to unity and i am a student, any help would be very grateful preferably javascript.

So, I wanted to make a message pop up basically when the player pass through the box collider.

I have made the image for the message.

This is currently my code

public var message: Texture2D
private var messagePopup: boolean

function OnCollisionEnter (myCollison : Collision) {
   {
    
}

and i am not even sure if this would work, my guess it wont… i am so bad at this… :smiley:

To display a texture on screen, you need to use the GUI.DrawTexture(…) function.

GUI functions also must be placed inside of OnGUI function.

Your code should look like this:

public var message: Texture2D
private var messagePopup: boolean
 
function OnCollisionEnter (myCollison : Collision)
{
   messagePopup = true;
}

function OnGUI()
{
   if(messagePopup == true)
   {
      GUI.DrawTexture(Rect(20,20,100,50), message);
   }
}

However if you need to display just a simple string, I recommend you to use GUI.Label function instead:

GUI.Label(Rect(20,20,100,50), "Your message");

You can find more about GUI in unity docs:

GUI Scripting Guide

GUI functions