Since we’re on the subject, when I click on my object and the GUI window appears, is there a way to make the GUI window appear at the location of the object?
Yes. You’ll just need to set the GUI Button’s rect so it’s “over” the selected model (or next to it, above it, whatever). You can use WorldToScreenPoint() to get the object’s position on screen and then build your Box rect relative to that:
var activeCamera : Camera;
var buttonRect : Rect;
var showGUI = false;
function OnMouseDown() {
buttonPosn = activeCamera.WorldToScreenPoint(gameObject.transform.position);
buttonRect = Rect(buttonPosn.x, buttonPosn.y, 100, 90);
showGUI = true;
}
function OnGUI() {
if (showGUI) {
GUI.Box (buttonRect, "Loader Menu");
}
}
You just need to drag-assign the current camera to the publicly exposed activeCamera variable. You need that to convert a world-position into an on-screen position so you can place the Box properly.
It would be a similar trick but instead of using WorldToScreenPoint you would use ScreenToWorldPoint to convert a screen position (the position of your GUI element) into a world position at which you place your GameObject of interest.