Popup window for individual game objects

OK I think I’ve got the problem licked here is my code just incase anyone else is pulling out their hair trying to do this… not sure if it’s the correct way to handle this but it seems to be working ok:

Now I wonder if I could trouble someone to tell me how to freeze my background while my pop up window is open & then unfreeze when it’s closed but still keep my background music playing lol

    var windowRect : Rect = Rect (20, 20, 120, 50);

var doWindow0 : boolean = false;



var aTexture : Texture;



function OnGUI () {

GUI.backgroundColor = Color.black;

GUI.contentColor = Color.yellow;











// Make sure we only call GUI.Window if doWindow0 is true.

if (doWindow0)

GUI.Window (0, Rect (350,250,800,500), DoMyWindow, "Suicide of T-Bear T-Shirt.");

}



// Make the contents of the window

function DoMyWindow (windowID : int) {



//I need to place a photo of the product here somehow?





if(!aTexture){

Debug.LogError("Assign a Texture in the inspector.");

return;

}

GUI.DrawTexture(Rect(10,70,402,402), aTexture);







// This is where I add my descriptive product text NOTE: Be sure to include the "

" in between your lines of text

var stringToEdit : String = "The attempted suicide of T. Bear T-Shirt

Inspird by a T.V. episode of Supernatural";

stringToEdit = GUI.TextArea(Rect(425,75,360,300), stringToEdit, 200);









if (GUI.Button( Rect(690,450.5,75,25),"Buy It")) {

Application.OpenURL("http://www.zazzle.com/t_bear_suicide_t_shirt-235455214631112735");

}



if (GUI.Button (Rect (680,20,100,20), "Close"))

doWindow0 = false;



}



function OnMouseDown()

{

doWindow0 = true;













}

It’s quite possible to do something like that with GUI.

First you’ll need a way to tell your pop-up window what to show. To do this you have several was, among which the following two :

  • Make a global variable containing the information you will fetch when you load your information window.

  • Pass the information as a parameter to the function that will build your information window.

Next you’ll need to think what your window will look like, it’s easier to make a formated window where only the text, image or links change rather than making a different looking window for each object.

After that, images are plain textures, so you can easily put a texture on a GUI element.

As for external links opening in a browser, you migh want to check this page.

I think everything i taked about is accessible in the free version of Unity, so you should be able to do it.