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 /
avatar image
0
Question by RetroGeek46 · Oct 22, 2017 at 11:11 AM · inputeventsystemlevel load

Difficulty with pausing and resuming EventSystem

I am making a pause screen for my game. Since there are multiple playable scene's I thought of having a pause scene and load it additive then and unload it, instead of prefabbing a canvas and instantiating every time.

Now some scene's have already have an Event System, so I disabled previous scene event system and enable when Pause scene unloads.

But the problem is that when I disable the event system script, the current input module gets set to none and remains that way even after being enabled.

Here's is part of Level Manger script responsible for loading Pause Scene (unload is handled from Pause Scene itself)

 private void Start()
     {
         if (FindObjectOfType<EventSystem>() != null){
             eventExists = true;
             es = FindObjectOfType<EventSystem>();
         }
     }
 
     private void Update(){
         if (Input.GetKeyDown(KeyCode.Escape) && !onPause) {             
             if (eventExists){
                 es.enabled = false;
             }
             SceneManager.LoadSceneAsync![alt text][1]("Pause", LoadSceneMode.Additive);
             StartCoroutine(SetActive(SceneManager.GetSceneByName("Pause")));
             Time.timeScale = 0;
             onPause = !onPause;                                  //onPause is a public static bool
         }
         if (!onPause && Time.timeScale == 0){
             if (eventExists) {
                 es.enabled = true;
                 Debug.Log("enabling event system");
             }
             Time.timeScale = 1;
         }
     }
 
     public IEnumerator SetActive(Scene scene){
         int i = 0;
         while (i == 0){
             i++;
             yield return null;
         }
         SceneManager.SetActiveScene(scene);
         yield break;
     }


[1]: /storage/temp/104209-input-unity.png

input-unity.png (46.1 kB)
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
Best Answer

Answer by RetroGeek46 · Oct 23, 2017 at 06:01 PM

Turns out I only had to call UpdateModules() on the event system object es after enabling the EventSystem once again at line 21. Also, this should be done when scene has completely finished unloading (which happens asynchronously) so just check for active scene to not be Pause before enabling it (add a condition in if statement SceneManager.GetActiveScene().name != "Pause")

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

82 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

Related Questions

EventSystem events reaching parent EventTrigger? 0 Answers

Hook up external Events into Unity Events System 0 Answers

How to evoke OnMouse Events with VR controller 0 Answers

StandaloneInputModule allowActivationOnMobileDevice vs forceModuleActive 0 Answers

How do I add a value to anywhere Input.GetAxis("Horizontal") is called? 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