Button OnClick on a mesh

Hello to everybody, I’m new and i’ve a problem:
I want to create a button that appears when the user click on an object. Can You help me please?

I tried to use this code:

function OnGUI () {
if (GUI.Button (Rect (10,10,150,100), “I am a button”)) {
print (“You clicked the button!”);
}
}

with the “OnClick” string but I don’t know where to put the string and if it will work.

Thank you very much to all that will help me.

You would have to make a raycast and have the raycast follow the cursor. Then when the raycast detects a mesh you click and does what you want to do. Download the Explosion Framework at Unity3d.com. This will have an example of a raycast following a cursor.

Thank You very much I’ll download the file and I’ll make you know if I have some other problems. Thanks!!!

Your Welcome!!!:smile: