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
1
Question by McAden · Jul 19, 2017 at 09:35 PM · inputsplash screen

How can I stop input while splash screen is displaying?

While the splash screen is displaying, input appears to be queueing up.

for example:

     if (Input.GetKeyUp(KeyCode.Escape))
     {
         Application.Quit(); // <-- I have a Debug breakpoint here
     }

If the user hits escape while the splash screen is displaying, the splash screen continues. However, after the splash screen is done, my breakpoint hits immediately.

I've tried this (before the above code):

     if(!SplashScreen.isFinished)
     {
         return;
     }

However, that doesn't resolve the issue. After the splash screen is finished, the Input.GetKeyUp(KeyCode.Escape) returns true and my breakpoint still gets hit. I assumed perhaps that the input simply isn't processed till then so what I needed was essentially to skip the first frame and let the GetKeyUp call get reset.

I added the following below the SplashScreen.isFinished call:

     if(!IsInitialized)
     {
         IsInitialized = true;
         return;
     }

So the first time the Update call is run, it simply returns. That frame is essentially skipped from checking input. However, that doesn't work if the user has pressed multiple keys (or the same key multiple times) as it's just processed on the following frame, and the one after that, and the one after that...

The only way I've successfully gotten this to actually work is to change my IsInitialized check to:

     if(!IsInitialized && !Input.GetKeyUp(KeyCode.Escape) && !Input.GetKeyUp(KeyCode.LeftArrow) && !Input.GetKeyUp(KeyCode.RightArrow) && ..) // <-- check every key my application uses
     {
         IsInitialized = true;
         return;
     }

     // Future calls are properly handled as the game is actually playing and the queued input is effectively flushed

However, this feels like a terrible, terrible hack. Is there any other logical way around this? Is this a bug in the splash screen? Is there a way to flush the input events after the splash screen is done?

Comment
Add comment · Show 3
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 Emperor · Jul 20, 2017 at 01:41 AM 0
Share

Just wanted to say a big thanks! I tried your last piece of code and that worked. Yes, it's hacky but at least it works so now I can finally move on to other things!

avatar image Glurth · Jul 20, 2017 at 05:02 PM 0
Share

I think(untested) the issue can be resolved by allowing Input.Get$$anonymous$$eyUp() to be called while you splash screen is active- just take NO action. I would expect this to "eat-up" those events. edit: Nope. according to docs: "You need to call this function from the Update function, since the state gets reset each frame." though "reset each frame" certainly seems to be contradicted by your results.

avatar image McAden Glurth · Jul 20, 2017 at 05:08 PM 0
Share

That would make sense in theory but doesn't work in practice. If I understand Unity correctly and I think what's happening is that the Get$$anonymous$$eyUp is all part of a messaging system. While the splash is playing the keyboard input is queued and my scene is loaded in the background. However, during this time my Update() script isn't running. After the splash screen is loaded, my script starts running its update. However, the Get$$anonymous$$eyUp messages accrued while the splash screen was playing so it's got n number of Get$$anonymous$$eyUps to burn through. It's not calls to Get$$anonymous$$eyUp that burn through the events and they are ins$$anonymous$$d eaten up by frames.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by McAden · Jul 21, 2017 at 08:14 PM

This has been repro'd and logged as a bug by the Unity team.

https://issuetracker.unity3d.com/issues/wsa-input-gets-queued-during-splash-screen-played-out-over-n-frames-after-splash-is-complete

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

78 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

Related Questions

splash image back button 0 Answers

Unity 2019.2.0f1. Game doesn't restart after back button pressed during splash screen display in android? 0 Answers

Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers

Comparing a player made image to an original image 1 Answer

Input refresh between scenes 0 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