1

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);
}
Serlite
  • 12,130
  • 5
  • 38
  • 49
Karz
  • 557
  • 1
  • 6
  • 22
  • I'll take a guess, is there a chance you have a script ordering problem? go to preferences script execution order, and try it with this script last, and then try it, first. There's a slim chance that will help. – Fattie Feb 11 '16 at 13:20
  • note that - sadly - the WebPlayer is still kind of an alpha, you know? it's a bit buggy / underperfected :/ – Fattie Feb 11 '16 at 13:21

1 Answers1

3

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,

Fattie
  • 27,874
  • 70
  • 431
  • 719