Script is detecting input with ZERO actions
https://docs.unity3d.com/ScriptReference/AsyncOperation-progress.html
When I uncomment these 3 lines in the script it's automatically starting the new scene by inputting space. Why is this happening? How do I prevent it from stopping? Space isn't pressed at all and it activates new scene. EDIT: Just to be more clear, when I press the button the scene immediately begins loading then activating the scene before any input or space being pressed. When I comment out these 3 lines it works as intended. Why do these lines break script? I'm using the code directly in the manual, with three additional lines:
 public GameObject m_BlackScreenImage;
 m_BlackScreenImage.SetActive(false);
 m_BlackScreenImage.SetActive(true);
Here is the full code with 3 additional lines commented out:
 //This script lets you load a Scene asynchronously. It uses an asyncOperation to calculate the progress and outputs the current progress to Text (could also be used to make progress bars).
 
 //Attach this script to a GameObject
 //Create a Button (Create>UI>Button) and a Text GameObject (Create>UI>Text) and attach them both to the Inspector of your GameObject
 //In Play Mode, press your Button to load the Scene, and the Text changes depending on progress. Press the space key to activate the Scene.
 //Note: The progress may look like it goes straight to 100% if your Scene doesn’t have a lot to load.
 
 using System.Collections;
 using UnityEngine;
 using UnityEngine.SceneManagement;
 using UnityEngine.UI;
 
 public class LoadingForMenu : MonoBehaviour
 {
     public Text m_Text;
     public Button m_Button;
     //public GameObject m_BlackScreenImage;
 
     void Start()
     {
         //Call the LoadButton() function when the user clicks this Button
         m_Button.onClick.AddListener(LoadButton);
         //m_BlackScreenImage.SetActive(false);
     }
 
     void LoadButton()
     {
         //Start loading the Scene asynchronously and output the progress bar
         StartCoroutine(LoadScene());
     }
 
     IEnumerator LoadScene()
     {
         yield return null;
 
         //Begin to load the Scene you specify
         AsyncOperation asyncOperation = SceneManager.LoadSceneAsync("Testing Ground");
         //Don't let the Scene activate until you allow it to
         asyncOperation.allowSceneActivation = false;
         Debug.Log("Pro :" + asyncOperation.progress);
         //When the load is still in progress, output the Text and progress bar
         while (!asyncOperation.isDone)
         {
             //Output the current progress
             m_Text.text = "Loading progress: " + (asyncOperation.progress * 100) + "%";
 
             // Check if the load has finished
             if (asyncOperation.progress >= 0.9f)
             {
                 Debug.Log("Game is loaded.");
                 //Change the Text to show the Scene is ready
                 m_Text.text = "Press space to continue";
                 //Wait to you press the space key to activate the Scene
                 if (Input.GetKeyDown(KeyCode.Space))
                     //m_BlackScreenImage.SetActive(true);
                     //Activate the Scene
                     asyncOperation.allowSceneActivation = true;
                     Debug.Log("Player activated game.");
             }
 
             yield return null;
         }
     }
 }
Your answer
 
 
             Follow this Question
Related Questions
How do i create a scene variable? 3 Answers
Save and load scene from file 2 Answers
Scene clones itself and switches continuously. 0 Answers
Why is my scene not loading? 2 Answers
[SOLVED]Problems loading the scene 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                