I actually have two questions here and I’m not sure if I should trouble people too much with asking twice so I’ll post both my problems with this script here:
1- How can I make this so it fits in the middle of the screen for all screen resolutions?
I noticed today that it fits perfectly on my screen middle when played on the stand alone player at 1680 X 1050 But NOT centered correctly if viewed at any other screen resolution???
2- I am having extreme difficulty trying to figure out and find any information on how to freeze my background when my pop up window is activated. So far all I’ve managed to do is stop the fps player from being able to walk around and limited the mouselook to only move horizontally so I’m still chasing my window around the screen in order to click on any of the buttons… Very frustrating.
3- I noticed that another problem I’m having with this is it seems to ignore this part of the code where I create a duplicate of this script for another T Shirt Pop Up Window and re name the “doWindow0” to “doWindow2”???
if (doWindow0) {
obj.GetComponent(FPSInputController).enabled = false;
GameObject.Find("Main Camera").GetComponent("MouseLook").enabled = false;
}
if (!doWindow0) {
obj.GetComponent(FPSInputController).enabled = true;
GameObject.Find("Main Camera").GetComponent("MouseLook").enabled = true;
}
I iave no idea why it’s doing this. Perhaps there is a better way of handling these pop up windows as I need to create a hell of a lot of them??
Here is my Code I have done so far:
var doWindow0 : boolean = false;
var aTexture : Texture;
var closeIcon : Texture2D;
var buyNowButton : Texture2D;
var obj : GameObject; // first person controller
function OnGUI () {
GUI.backgroundColor = Color.black; //Background Color of Window
GUI.contentColor = Color.yellow; //Color of text within my Window
// 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.");
///// Stops player from walking around while viewing the pop up window
if (doWindow0) {
obj.GetComponent(FPSInputController).enabled = false;
GameObject.Find("Main Camera").GetComponent("MouseLook").enabled = false;
}
if (!doWindow0) {
obj.GetComponent(FPSInputController).enabled = true;
GameObject.Find("Main Camera").GetComponent("MouseLook").enabled = true;
}
}
// Make the contents of the window
function DoMyWindow (windowID : int) {
//This is where I place my Product Photo @ 402 X 402 pixels in size
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
Comfortable, casual and loose fitting, our heavyweight t-shirt will quickly
become one of your favorites. Made from 6.0 oz, pre-shrunk 100% cotton,
it wears well on anyone. We’ve double-needle stitched the bottom and
sleeve hems for extra durability. Imported.”;
stringToEdit = GUI.TextArea(Rect(425,75,360,300), stringToEdit, 500);
//This is my Web Link Button
if (GUI.Button( Rect(610,430,179,60), buyNowButton)) {
Application.OpenURL("http://www.zazzle.com/t_bear_suicide_t_shirt-235455214631112735");
}
if (GUI.Button (Rect (752,20,30,30), closeIcon))
doWindow0 = false;
}
//This is my Close GUI Window Button
function OnMouseDown()
{
doWindow0 = true;
}