Button doesn't work when returning to scene (android)

Using Unity 5.6.3p2

Building a game for Android.

I have a scene called “Main” that is active when the app starts. There is a single button called “Create”. Button takes you to “Scene2”. In Scene2, there is a button called “Save”. “Save” does some stuff in a function, and the last line of that function is: SceneManager.LoadScene(“Main”);

The function works… the things that are supposed to happen happens, and then the user is returned to “Main”.

However, Now the “Create” button no longer works. It still highlights when you press it, but it doesn’t take you to “Scene2” anymore.

???

My “Main” Scene does have an “EventSystem” and I do have “Force Module Active” in the checked state.

My question is similar to UI Buttons Stop Working After I Load Another Scene And Then Come Back. - Questions & Answers - Unity Discussions but I think the answers are not applicable to the current version of Unity.

More details I should probably add:

In my “Main” scene, I have a object I call the “Game Controller”. Within this object is a script component and that contains this:

void Awake ()
	{
		if (Instance == null) {
			DontDestroyOnLoad (gameObject);
			Instance = this;
		} else if (Instance != this) {
			Destroy (gameObject);
		}

	}

(I should also add that I’m fairly new to Unity)

The DontDestroyOnLoad on your GameController is relevant (i.e. affects) only the GameController. The comment refers to the GameObject of the EventSystem, i.e. the GameObject named EventSystem, with the EventSystem component to it. Although I had second thoughts about it, what the comment meant, was to include another custom script in the EventSystem GameObject, with the DontDestroyOnLoad (gameObject) statement in Awake() (as you’ve done for your GameController).

However, as I’ve said above, I’ve had second thoughts about this, since your “Main” Scene already includes an active EventSystem, which responds to the click of your button, and takes you to Scene 2, which also includes an active EventSystem, as you can, again, click on the button and go to back to the “Main” Scene.

Therefore, to start with, the EventSystems in both scenes function properly, so there’s no question about using a DontDestroyOnLoad statement to preserve any EventSystem.

Additionally, since the EventSystem in the “Main” Scene starts active, when this scene loads again (after Scene 2) the EventSystem should, be in an active state again.

Just to make sure, please check if the EventSystem is active in the Hierarchy of the “Main” Scene, after returning from Scene 2.

Is there a reason why you are not using one of the latest Unity versions? I am using v.2017.2.1 and I tried to replicate the problem, but couldn’t.

I just created a button in an empty scene, and attached the following script to it:

using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneChanger : MonoBehaviour
{
    public int NewScene;

    public void ChangeScene()
    {
        SceneManager.LoadScene(NewScene);
    }
}

I configured the button’s Inspector to runChangeScene() on each button click, duplicated the scene, and added both scenes to the build settings. I also set the NewScene variable to ‘1’ in Scene 1, and ‘0’ in Scene 2.

The scenes were changing back and forth just fine, both in Editor Play mode, as well as in the Android build I made.

So, maybe you should try and replicate the above in a new empty project. If you still have a problem, it could be related to the Unity version you are running.

Otherwise, there could be something in your code, which prevents scene 2 to load the second time, in which case, it would be good to post some of your code.