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 MaxLohMusic · Feb 21 at 12:25 AM · cursorcursor-customizationruninbackground

How to make custom cursors work without enabling "Run in Background"?

The cursors don't work anymore after alt-tabbing out of and back into the game, unless "run in background" is enabled. I'd prefer not to enable "run in background" so the music of the game can stop playing when the game is alt-tabbed. But in this case, the cursors will no longer work when hovering over objects and the cursor will just always be the system default.

How do I make the custom cursors work without specifying "run in background"?

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
1

Answer by Bunny83 · Feb 21 at 01:15 AM

You just don't. You don't want the game to run in the background, so it can not update anything in your game, that includes software cursors as they are just another quad rendered by the game. So when you're loosing focus and "run in background" is not enabled, the game will not update or render anything.


The background music should be the least of your problems. You can disable the background music when your application looses focus manually, if that's the only thing you care about. You can manually disable the background music, but you can not manually make something happen (like updating a software cursor) when you don't let your game run in the background.

Comment
Add comment · Show 4 · 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
avatar image MaxLohMusic · Feb 21 at 01:56 AM 0
Share

That's a good idea for a workaround, thanks for your input.

To clarify, I do not need the game to update any cursors while it's in the background. I'm talking about when the user alt-tabs to something and then goes back into the game (updated my question to fix the wording). The game is thus no longer in the "background", but the cursors are permanently broken after doing this once. This seems like a bug in Unity so I am curious how others have handled this problem. Perhaps the workaround you described is the best solution.

avatar image Eno-Khaon MaxLohMusic · Feb 21 at 02:45 AM 0
Share

You can make use of OnApplicationFocus() as a place to reset state-specific, break-prone elements.

avatar image MaxLohMusic Eno-Khaon · Feb 21 at 03:55 AM 0
Share

IIUC you are saying I can set run in background to false and still keep the cursor functionality after alt-tab; however, I'm not sure which part "broke" because the cursor code only lives in hover event; these hover events are still triggered but the cursor no longer changes correctly. Do you know exactly what code to put in OnApplicationFocus() to make it work?

Show more comments

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

135 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

Related Questions

How Do I Lock the Cursor to the Center of the Screen? 1 Answer

cursor misbehaves in the UI 0 Answers

change mouse cursor on mouseover 3 Answers

How do I define the SetCursor Script? 1 Answer

How Can I Lock The Cursor Position? 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