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 draky · Apr 03, 2019 at 06:24 AM · windowswindowed

Find if windowed mode has been maximised

Hey everyone,

I am running into an issue where i am trying to detect when a user has maximised a unity window from windowed mode. I've tried comparing Screen.height / width against Screen.currentResolution but when maximising from windowed mode, Screen.height takes into account the task bar so it never reaches currentResolution.height.

Is there a event or another way i can check to see if the user has maximised the window? I cant seem to find anything on the internet.

This is a windows project.

Cheers!

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 Bunny83 · Apr 03, 2019 at 12:51 PM 0
Share

Do you mean a maximized window or fullscreen mode? A maximized window is still a window. So it could have any size the user want. If you're looking for the maximized status of the native OS window, you would need to use native OS API methods to deter$$anonymous$$e the window state. For windows you would have to dive into pinvoke calls to the WinAPI. This should be a good start. Installing hooks can be problematic but would directly give you a callback when it got maximized. Using GetWindowPlacement lets you query the maximized state on demand.


Though you should ask yourself if you really need to know this. If your window is resizable, the user would have full control over moving and resizing the window to any size. A maximized window is just "one" window size from the applications perspective. The special "maximized state" is just relevant for the OS.


So what's the exact usecase?

avatar image draky Bunny83 · Apr 08, 2019 at 06:34 AM 1
Share

Hey @Bunny83,

I mean maximized window, not full screen.

So use case is we are designing an editor i guess you could say similar to Unity. We have limited the user to stay at a ratio of 16:9 when resizing their windowed window, if they in fact choose to go windowed and not fullscreen. So whether they stretch vertically or horizontally, it will always stay at a 16:9 ratio to stop stretching (As we do no support dynamic windows yet).

But if they double click the top tab of the window and its maximised to their current screen res, thats when things get a little weird. Hence why i would like to know when it is done to try and handle it.

It is something we would very much like. It is not necessary or a must have so just doing research and seeing if it is worth / good enough to implement.

avatar image sewy draky · Jan 05, 2021 at 06:26 PM 0
Share

Hello, have you found out? Same problem here.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Zaeran · Jan 06, 2021 at 06:19 AM

You can't tell if the window itself has been maximised or not, because Unity doesn't give you that low level access to their windows.

What you could possibly do is use Screen.width/height, or Display.displays[0].renderedWidth/Height to check the size of the window when it comes back into focus after being maximised, using OnApplicationFocus(), and then use that to determine what behaviour you want to happen

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

108 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

Related Questions

Standalone player in windows open fullscreen, but player settings says windowed 1 Answer

How can you remove the title bar from a windowed unity project? 1 Answer

Failing Builds 0 Answers

Windows toolbar showing in fullscreen mode 1 Answer

How can i put windows? 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