Advertisement

EventSystem doesn't work in Build version

Started by August 05, 2023 01:29 PM
1 comment, last by Alberth 1 year, 4 months ago

Hello again (today second time)

Problem

I have a game with 2 scenes and one EventSystem in second scene. As I can understand EventSystem can be only in one scene and in this case I've found LoadSceneMode.Additive method that works fine in editor but gives freezed first screen in Build version.

Here are scripts for my both scenes

Scene one (menu) :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class menu : MonoBehaviour
{

    public void PlayGame()
    {
        SceneManager.LoadScene(1);
    }

    public void QuitGame()
    {
        Debug.Log("Quit OK");
        Application.Quit();
    }

}


And the second scene (marked as Active Scene)

public class PauseMenu : MonoBehaviour
{
    public static bool GameIsPaused = false;

    public GameObject pauseMenuUI;

    void Update()
    {
        if(Input.GetKeyDown(KeyCode.Escape))
        {
            if(GameIsPaused)
            {
                Resume();
            }
            else
            {
                Pause();
            }
        }
    }


    public void Pause()
    {
        pauseMenuUI.SetActive(true);
        Time.timeScale = 0f;
        GameIsPaused = true;
    }


    public void Resume()
    {
        pauseMenuUI.SetActive(false);
        Time.timeScale = 1f;
        GameIsPaused = false;
    }

    public void LoadMenu()
    {
        SceneManager.LoadScene(0, LoadSceneMode.Additive);
        pauseMenuUI.SetActive(false);
        Time.timeScale = 1f;
        GameIsPaused = false;
        Debug.Log("Scene change activated");
    }

    public void QuitGame()
    {
        Application.Quit();
        Debug.Log("Quit activated");
    }


}

And my hierarchy screenshot

Please assist, what do I miss to do in order to work in Build version as good as in editor mode?

Thank you

Development builds and production builds often behave differently. While you may consider the development build behavior as more desirable, that does not mean it is supposed to work that way. It may very well happen accidentally, or even be intentional for making switching to a different scene simpler while testing (and testing only).

Given that you use a commonly used engine, I'd be surprised if you are the first person with 2 scenes and one event system. Did you try finding other discussions about this problem? Did they point out to directions or even solutions?

This topic is closed to new replies.

Advertisement