Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 kyin · Mar 29, 2011 at 03:53 AM · screenwindowfocus

can you focus and unfocus your unity program

I am making a program with unity where I was going to make the program come to the front of the the screen. I was going to make it do this like every 15 min. and when I say front of the screen I mean over other windows like a internet browser. Is there a way to do this.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by jonas-echterhoff · Mar 29, 2011 at 12:52 PM

Only by writing a plugin.

Comment
Add comment · Show 1 · 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 Statement · Mar 29, 2011 at 01:42 PM 0
Share

I think this would be the easiest way to go about with the current feature set of Unity3D.

avatar image
1

Answer by Statement · Mar 29, 2011 at 01:37 PM

The best way I could get about is to set screen resolution. This pops up the window on my machine but only if the the player first was fullscreen and then is windowed, and that it isn't minimized but just behind any other window. So it's probably not really ideal for your needs. For some reason I don't seem to get OnApplicationFocus event when I tab out of a fullscreen game...

Anyhow if you're interested anyway, here's my code for this test:

var popupTimer : float = 5; Application.runInBackground = true;

function OnApplicationFocus (focus : boolean) { if (focus) CancelInvoke("Restore"); else InvokeRepeating("Restore", popupTimer, popupTimer); }

function Restore() { Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, Screen.fullScreen, Screen.currentResolution.refreshRate); }

Comment
Add comment · Show 3 · 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 Statement · Mar 30, 2011 at 11:38 AM 0
Share

Yeah, I said it ain't ideal since you have to first go fullscreen, then windowed, and then not $$anonymous$$imize it. $$anonymous$$ake sure you read my whole answer.

avatar image Statement · Mar 30, 2011 at 11:38 AM 0
Share

This is more of a hack than a solution. I wouldn't count on it working predictably.

avatar image Sarchophagi · Apr 25, 2018 at 07:37 AM 0
Share

Thanks for the workaround. Got useful 7 years later with little modifications. I need to focus my game window when a match is found, in case user $$anonymous$$imized or alt+tabed it.

So I just use SetResolution to set game fullscreen and then use a 0.01f Invoke to return it to original windowed size. Game window focused. Works like a charm with no DLL needed.

avatar image
0

Answer by astracat111 · Jun 27, 2019 at 05:39 PM

Using System32 api maybe?

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

C# Tooltips through multiple windows 1 Answer

Game with 2 separate windows 2 Answers

Easy way to make buttons in-accessible when under a pop-up window? 1 Answer

Editor window full screen 2 Answers

How do i keep my game from losing focus 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