Hi, I recently game across a problem. Whenever I press the play button, unity sits there and takes forever to load the game. I have waited about 20 minutes and nothing has happened. Everything was working fine until I added these two scripts:
MenuScript.js:
var isOnList: boolean;
MenuManager.js:
#pragma strict
var MenuList : GameObject[];
var MenuID : int;
var TotalMenus : int;
var MenuActive : boolean;
var ActiveMenus : int;
function Start () {
TotalMenus = UnityScript.Lang.Extensions.get_length(MenuList);
}
function Update () {
while (MenuID < TotalMenus)
{
if (MenuList[MenuID].activeInHierarchy)
{
ActiveMenus = ActiveMenus + 1;
if (!MenuList[MenuID].GetComponent(MenuScript).isOnList)
{
MenuList[MenuID].GetComponent(MenuScript).isOnList = true;
}
MenuID = MenuID + 1;
}
else
{
if (!MenuList[MenuID].activeInHierarchy)
{
if (MenuList[MenuID].GetComponent(MenuScript).isOnList)
{
ActiveMenus = ActiveMenus - 1;
MenuList[MenuID].GetComponent(MenuScript).isOnList = false;
MenuID = MenuID + 1;
}
}
else
{
MenuID = MenuID + 1;
}
}
}
if (ActiveMenus != 0 && !MenuActive)
{
MenuActive = true;
}
if (ActiveMenus == 0 && MenuActive)
{
MenuActive = false;
}
if (PlayerPrefs.GetInt("MenuActive") != 1 && MenuActive)
{
PlayerPrefs.SetInt("MenuActive", 1);
}
if (PlayerPrefs.GetInt("MenuActive") != 0 && !MenuActive)
{
PlayerPrefs.SetInt("MenuActive", 0);
}
}
This is very annoying and I want to get a new build of my game out by March 15th, 2016. Thank you in advance.