I encountered a problem with the WebPlayer in Unity.
My game has a few canvases deactivated in the beginning of my code with SetActive
. In the editor or desktop version, these canvases are properly deactivated.
But when I build a webplayer version, they are not. All displayed. I updated everything but no change.
Here is my code :
void Start ()
{
base.Start();
MusicLoopsManager.manager.PlayMusic(MusicType.menuMusic);
mode = GameObject.Find("Mode") as GameObject;
modeState = ModeState.play;
pause = GameObject.Find("Pause") as GameObject;
resume = GameObject.Find("Resume") as GameObject;
retry = GameObject.Find("Retry") as GameObject;
exit = GameObject.Find("Exit") as GameObject;
titleCanvas = GameObject.Find("TitleCanvas") as GameObject;
levelSelectionCanvas = GameObject.Find("LevelSelectionCanvas") as GameObject;
hudCanvas = GameObject.Find("HUDCanvas") as GameObject;
pauseCanvas = GameObject.Find("PauseCanvas") as GameObject;
victoryCanvas = GameObject.Find("VictoryCanvas") as GameObject;
levelSelectionCanvas.gameObject.SetActive(false);
hudCanvas.gameObject.SetActive(false);
pauseCanvas.gameObject.SetActive(false);
victoryCanvas.gameObject.SetActive(false);
}
Note apart from anything else, you can not go
base.Start()
in Unity."Start" just does not work like that - it's a magic function, it's almost like a bit of preprocessor syntactic candy.
You can google much about the issue.
So in the first instance, do not do that or try to do it.
If you are using derived classes, simply DO NOT try to do anything in Start. Have your own function - say, "Begin" or "Setup" - and use that entirely. Just call it from Unity's magic
Start
,