I see a couple of other posts like this, but none of them explain how they resolved.
I’m doing the platformer tutorial and I’ve noticed that the tutorial differs a little from how Unity looks now, but I’ve puzzled through most of it.
Now I’m at a roadblock when it comes to the start screen. (page 56 - 63 of the tutorial). All I’m seeing when I run the new scene that you create at this point is a blank blue screen. The music loop works fine, however.
Here’s my StartMenuGUI.js file.
Any help is appreciated.
//Make the script also execute in edit mode
@script ExecuteInEditMode()
var gSkin : GUISkin;
var backdrop : Texture2D; // Our backdrop image goes here.
private var isLoading = false; //if true, we'll display the "Loading..." message.
function onGUI()
{
if(gSkin)
GUI.skin = gSkin;
else
Debug.Log("StartMenuGUI: GUI Skin Object missing!");
var backgroundStyle : GUIStyle = new GUIStyle();
backgroundStyle.normal.background = backdrop;
GUI.Label ( Rect( (Screen.width - (Screen.height * 2)) * 0.75, 0, Screen.height * 2, Screen.height), "",backgroundStyle);
GUI.Label ( Rect( (Screen.width/2) - 197, 50, 400, 100), "Lerpz Escapes", "mainMenuTitle");
if(GUI.Button( Rect( (Screen.width/2) - 70, Screen.height - 600, 140, 70), "Play"))
{
isLoading = true;
Application.LoadLevel("TheGame"); // load the level
}
var isWebPlayer = (Application.platform == RuntimePlatform.OSXWebPlayer || Application.platform == RuntimePlatform.WindowsWebPlayer);
if(!isWebPlayer)
{
if(GUI.Button ( Rect( (Screen.width/2) - 70, Screen.height - 80, 140, 70), "Quit")) Application.Quit();
}
if(isLoading)
GUI.Label ( Rect( (Screen.width/2) - 110, (Screen.height/2) - 60, 400, 70), "Loading...", "mainMenuTitle");
}
while delving through the forums for an answer, I came across someone who was able to get past what I was experiancing. Only they just needed to attach the script to Main Camera.
Since I had already done that, I copied thier script from the forums and replaced mine and now it works.
I need to learn from my mistake, though, and I’ve been starting at my script side by side with his (that works) for about 30 minutes and outside of some spaces, I can’t see the difference.
Would someone show me where I went pearshaped?
My script is posted above, here’s the one that works.
//Make the script also execute in edit mode
@script ExecuteInEditMode()
var gSkin : GUISkin;
var backdrop : Texture2D; // our backdrop image goes here
private var isLoading = false; //if true we will display the loading... message
function OnGUI () {
if (gSkin)
GUI.skin = gSkin;
else
Debug.Log("StartMenuGUI: GUI Skin object missing!");
var backgroundStyle= new GUIStyle();
backgroundStyle.normal.background= backdrop;
GUI.Label (Rect( (Screen.width-(Screen.height*2))*0.75,0,Screen.height*2,Screen.height), "", backgroundStyle);
GUI.Label (Rect( (Screen.width/2)-197,50,400,100), "Lerpz Escapes", "mainMenuTitle");
if (GUI.Button( Rect((Screen.width/2)-70, Screen.height - 160,140,70), "Play"))
{
isLoading =true;
Application.LoadLevel("TheGame"); // load the game level
}
var isWebPlayer = (Application.platform == RuntimePlatform.OSXWebPlayer || Application.platform == RuntimePlatform.WindowsWebPlayer);
if (!isWebPlayer)
{
if (GUI.Button( Rect( (Screen.width/2)-70, Screen.height -80,140,70), "Quit"))
Application.Quit();
}
if (isLoading)
GUI.Label ( Rect( (Screen.width/2)-110, (Screen.height/2) -60,400,70),"Loading ..." , "mainMenuTitle");
}
Found it.
I messed up the variable assignment for backgroundStyle.
I put in
var backgroundStyle= new GUIStyle();
when it should have been
var backgroundStyle : GUIStyle = new GUIStyle();
Fast finger mistake, I guess.
-Seth