- Home /
Trouble with start menu/loading screen script
So, I tried to add a start menu and a loading screen to my game (both are their own scene), but for some reason these scripts work perfectly fine in the editor, however whenever I make a build it screws up the game (it appears it initializes the game once per frame since it makes the camera jerk back and forth and I can't do anything that doesn't get immediately reset) When I make a build without the start menu and loading screen scenes it works fine. I'm going to start searching around the interwebs more in-depth but I figured I'd post this here first.
Here is the code that I have for the start menu (I believe the problem occurs in the loading code however):
var logo : Texture;
var background : Texture;
function OnGUI(){
GUI.DrawTexture(Rect(0,0,Screen.width, Screen.height), background, ScaleMode.StretchToFill, true, 0);
GUI.DrawTexture(Rect((Screen.width/3),(Screen.height/3),(Screen.width/3),(Screen.height/3)), logo, ScaleMode.StretchToFill,true,0);
if (GUI.Button(Rect((Screen.width/6)*2.3, (Screen.height / 8) * 7, Screen.width / 6, Screen.height/8),"Start")){
Application.LoadLevel("Loading");
}
}
And then here is the loading code:
var background : Texture;
var loaded : boolean = false;
var startGame : boolean = false;
function OnGUI(){
Debug.Log("Helloooooo");
GUI.DrawTexture(Rect(0,0,Screen.width, Screen.height), background, ScaleMode.StretchToFill, true, 0);
Loaded();
if (loaded == true){
Debug.Log("loading done");
if (GUI.Button(Rect((Screen.width/6)*2.3, (Screen.height / 8) * 7, Screen.width / 6, Screen.height/8),"Done Loading, click here to continue")){
startGame = true;
}
}
}
function Loaded(){
var isDone : boolean = false;
var async : AsyncOperation = Application.LoadLevelAsync("may1st");
var textures : Object[] = Resources.LoadAll("Textures", Texture2D);
var objects : Object[] = Resources.LoadAll("Objects",GameObject);
yield async;
}
Any tips or help is very much appreciated! Thanks! (:
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Using ScriptableObjects data loaded with the Addressable Package 0 Answers
Loading Audioclip from Resources fails in Build 0 Answers
loading progress scene slows down game framerate 1 Answer
LoadAsync is blocking? 1 Answer