Display a window with a message when the game object is clicked

Hi all… I’m new to Unity and scripting. Can anyone help me with a simple thing? I can’t find this thread on the internet so I’m asking here:

How to display a window with a message when I click the mouse button on the object and when I’m quite close to it? And I would also be able to display a GUI icon like “Click the left mouse button to interact”.

I’ve posted two example images in order to be more clear with my question.


Thank you very much guys!!

you’re gonna need to look into raycasting, a very easy way would be to make a script to put on the object itself with the built in onmousedown function

on mouse down

on gui

and in the onmousedown function toggle a boolean variable on/off

then in the ongui function show the picture depending on the variable,

so like a script like this on the object you want to click:

private var GUIToggle = false;

function OnMouseDown () {
    GUIToggle = !GUIToggle;   //switches to opposite boolean

function OnGUI () {

     if(GUIToggle == true)
          //here you put the code for a picture
          //(using a gui label or whatever you want)