Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
avatar image
0
Question by J_Ripley · Dec 14, 2021 at 11:16 PM · buttonscripting beginnerscreenmenu screen

Wrong Scene loading from Pause

When I am in Pause state, and click on the Resume to Level button, instead of it going to the game, it goes to the main menu. No matter what number I type in the parentheses. The code and picture follows: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;

public class PauseGame : MonoBehaviour { public bool gamePaused = false; public AudioSource levelMusic; public GameObject pauseMenu; public AudioSource pauseJingle;

 void Update()
 {
     if (Input.GetButtonDown("Cancel"))
     {
         if(gamePaused == false)
         {
             pauseJingle.Play();
             Time.timeScale = 0;
             gamePaused = true;
             Cursor.visible = true;
             levelMusic.Pause();
             pauseMenu.SetActive(true);                
         }
         else
         {
             pauseMenu.SetActive(false);
             levelMusic.UnPause();
             Cursor.visible = false;
             gamePaused = false;
             Time.timeScale = 1;                
         }
     }
 }
 public void ResumeGame()
 {
     pauseMenu.SetActive(false);
     levelMusic.UnPause();
     Cursor.visible = false;
     gamePaused = false;
     Time.timeScale = 1;
 }

 public void RestartLevel()
 {
     pauseMenu.SetActive(false);
     levelMusic.UnPause();
     Cursor.visible = false;
     gamePaused = false;
     Time.timeScale = 1;
     SceneManager.LoadScene(3);![alt text][1]


[1]: /storage/temp/189959-pause.jpg

pause.jpg (111.1 kB)
Comment
Add comment · Show 6
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
avatar image CodesCove · Dec 15, 2021 at 06:43 AM 0
Share

.. where are you calling the RestartLevel() ?

avatar image J_Ripley · Dec 15, 2021 at 03:11 PM 0
Share

Thank ou CodesCovealt text

When the game is paused I have three links or buttons as shown on this attached picture.

pausequestion1.jpg (105.9 kB)
avatar image J_Ripley J_Ripley · Dec 15, 2021 at 03:20 PM 0
Share

In the inspector you can see how the RestartLevel () function is called from the script on the attached picture which apparently refuses to upload for you to see

avatar image J_Ripley J_Ripley · Dec 15, 2021 at 03:26 PM 0
Share

Since this will not allow me to upload a second picture I can be reached by e-mail at josephripley69@gmail.com

avatar image rage_co J_Ripley · Dec 16, 2021 at 11:39 AM 0
Share

Instead of using simply 3, try using SceneManager.GetActiveScene().buildIndex?

avatar image CodesCove J_Ripley · Dec 15, 2021 at 04:16 PM 0
Share

Add Debug.Log("Scene Path: " + SceneUtility.GetScenePathByBuildIndex(3)); to the RestartLevel() function before the LoadScene and check what is written in the Console window.

if nothing is written then it's not actually called. Otherwise you get info about what scene is actually loaded.

PS. You should be able to add more that one image here.

0 Replies

· Add your reply
  • Sort: 

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

169 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 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

How to make Iphone Menu-Unity 2 Answers

How do I run a script when a button is highlighted 3 Answers

how to have an object positioned relative to the screen(like a button) 1 Answer

Is there a way to lock GUI buttons to a screen position insted of a pixel defined position so it will show up no matter the resolution of the screen? 0 Answers

Make buttons visible in the editor? 2 Answers


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