Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Footloose93 · Oct 13, 2016 at 03:42 PM · scenegametimeloading

Pause scene?!?

Hey there, I have a little big question.

I am a big noob so I need some help with it.

In my first scene I have the main menu. When I press the Start Button, it destroys this scene and loads an other scene, the ingame scene.

So now I want the following things to happen: - When I pres ESC the ingame scene should be paused (maybe with "Time.timeScale = 0;"). - The main menu scene should be loaded. The ingame Scene should not be destroyed. - When I press Escape again the main menu scene should be destroyed, it should go back to the ingame scene and the Game should be unpaused ("Time.timeScale = 1;").

Right now, this is my (uncomplete) code: using UnityEngine; using System.Collections; using UnityEngine.SceneManagement;

 public class ButtonManagerIngame : MonoBehaviour {
     
     bool Pause = false;
 
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () {
         
     }
     public void PausiereSpiel(string PauseGameLevel, string newGameLevel)
     {
         
         if (Input.GetKeyDown ("escape")) {
              if(Pause == true){
                  Time.timeScale = 1.0f;
                  SceneManager.LoadScene(newGameLevel);

                  Pause = false;
              } else {
                  Time.timeScale = 0.0f;
                  Pause = true;
                  DontDestroyOnLoad(transform.PauseGameLevel);
              }
         
     }
 }
 }

Anyway I get compiler errors, but I don't think it works this way... Can anyone help me?

The Reason why I want a scene and not a canvas is, that I am not so good in Unity and I already have a finished Main menu scene I want to use for now.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by FirePlantGames · Oct 14, 2016 at 08:32 PM

You can just use SceneManager.LoadScene (newGameLevel, LoadSceneMode.Additive); This adds the scene to the current scene. Using your code it would go something like this; public GameObject PauseSceneRoot;

      void Start ()
      {
                        SceneManager.LoadScene ("PauseSceneName", LoadSceneMode.Additive);
 
     PauseSceneRoot = GameObject.FindWithTag ("PauseMenu") //Have all your pause scene objects, inside one object with the tag "PauseMenu" or this won't work
      }
 
       void Update ()
       {
               if (Input.GetKeyDown ("escape"))
                         Pause = !Pause;
                             
               Time.timeScale = (Paused)? 1.00f : 0.00f; //If your time scale isn't working, change Paused to !Paused
               PauseSceneRoot.SetActive(Paused);
       }




Let me know how that works.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

107 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Correct Call function On Gui ? 0 Answers

My project's UI keeps resizing itself and I have no idea why. 0 Answers

when i load scene 2, score adds automatically x6 (Weird bug or something) 2 Answers

How do I load scene using scene manager Set Active Scene build index / ManagerScenes are not loading Build index 0 Answers

Is there a way to load Scenes quicker? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges