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 alfarmer · Nov 25, 2012 at 05:38 PM · resolutionscreenwindow

iOS status bar

Hello.

I'm using Unity 4.0 and the following two calls are returning the same values (2048x1536) on iPad 3: Debug.Log(Camera.main.pixelWidth); Debug.Log(Camera.main.pixelHeight); Debug.Log(Screen.width); Debug.Log(Screen.height);

This makes sense when running in full-screen mode, but if I run with the statusBar turned on I would expect the 1536 value to be smaller to account for the status bar height. Unfortunately it's rendering my game full-screen and then the top portion of the game is covered up by the status bar.

This is not the behavior I would expect. Is there some other variable somewhere that must be set for Unity to set the WINDOW/VIEW size appropriately?

Note: This is also an issue on Android devices with Touchwhiz, etc. It's even an issue on Windows or Mac when running in Windowed mode. So it doesn't seem like functionality Unity would be missing?

Comment
Add comment · Show 5
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 Fattie · Nov 25, 2012 at 07:07 PM 0
Share

Hmm, seems correct to me. the status bar comes "over" your app.

you want the screen ration proportions of your game to be that of the glass.

if you want to allow for the status bar (perhaps for your own GUI or whatever), just check if it is turned on and allow for it.

avatar image alfarmer · Nov 25, 2012 at 07:37 PM 0
Share

No, it's not correct. If the status bar or anything like it reduces the size of the Window/View visible area then Unity should provide the size of that Window/View in addition to providing the screen size. That's the only way anyone can compute the difference in a platform-independent way because the size of such things varies greatly.

avatar image alfarmer · Nov 26, 2012 at 12:12 AM 0
Share

Perhaps you don't understand what I'm saying because the functionality I'm talking about is TRIVIAL and is provided by both Android and iOS -- each of which draws a distinction between the "Screen" size and the dimensions of the underlying "EAGLView". I've used that functionality in my own OpenGL engines for years, so I'm saying this with absolute certainty -- I have plenty of product in the field today that does just this.

Saying that EVERYONE should render "to the glass" because Unity somehow shouldn't expose this critical operational distinction to the scripting engine is both an arrogant and uninformed opinion. While standard indie video game developers may not care about the distinction between "screen" and "view", I can assure you there are plenty of PAYING UNITY CUSTO$$anonymous$$ERS that do.

If the answer is simply "Unity fails to implement this trivial functionality" then fine. I think it's incredibly stupid because developers will need to create custom, platform-specific code just to support status bars on iOS and home bars on Android -- and that defeats the entire purpose of a cross-platform solution such as Unity.

And if you don't want to believe me, look no farther than Cocos2Dx. They expose this basic and necessary information for a considerably smaller sum of money.

avatar image Radazen2 · Jan 18, 2013 at 03:59 AM 0
Share

Honestly, I'm still puzzled by the fact that Unity doesn't account for this or have a way to do it. If you want to anchor UI buttons at the top of the screen, you need to know where the top of the screen actually is. Having the status bar cover any of your UI is not what users expect from polished applications, and certainly not what I'd expect from a high-end engine like Unity. The original post isn't asking for a "convenience function," it's asking for the functionality at all. You can use hackish workarounds (like identifying what iPhone device you're running on and hard-coding the status bar height accordingly), but that's not very robust (see: http://stackoverflow.com/questions/3888517/get-iphone-status-bar-height -- am I supposed to write hard-coded logic in Unity to see if the device is using tethering, too?).

avatar image GamerCB · Mar 21, 2013 at 12:35 PM 0
Share

I agree with Alfarmer and Radazen2 too. This is a basic requirement and if it may upset some other users then it could be made as an option. I've written a cross platform product and so it copes with different screen sizes and so if it reports a smaller screen due to a status bar taking some up it would just work automatically with or without the bar.

2 Replies

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

Answer by Fattie · Nov 25, 2012 at 07:44 PM

The camera IS rendering to the glass size. so that's the size you need to know. "something else" (the OS) is adding something over the top.

NOTE:

you certainly can, if you want, set the rendering area of the camera, so that it only renders to the area "not including the status bar".

so, your monsters etc would NOT be rendering under the status bar.

if your point is, Unity should make a convenience function, for iOS users (like me) that does that ... well, fair enough. Unfortunately it does not have that, so simply do the calculation yourself.

(for the nightmare world of "android", there are too many possibilities!!)

exactly as you say "it's rendering my game full-screen and then the top portion of the game is covered up by the status bar."

"This is not the behavior I would expect." FWIW every iOS develop would disagree with you.

But the critical point is, does Unity offer a convenience function to do what developers "like you" need? they do not, so write the one line of code yourself.

I can't think of any reason I would even care if the IOS is covering a sliver at the top of my screen.

If could be the case that a client would say to me "oh, sometimes the OS bar is covering those buttons you have that are really near the top of the screen"

in that case I would ............................. have the designers move the buttons down a little! heh!

simple !

Comment
Add comment · Show 6 · 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 GamerCB · Mar 21, 2013 at 12:50 PM 0
Share

So how do I calculate how much my designers should move the buttons down by? Don't forget this must cover all iOS devices and Android devices, now and in the near future.

OR

How do I calculate the render area not including the status bar? I can't find any way to get the size of the status bar for any particular platform.

All I want is my own 2D top banner parked at the top of the visible screen.

avatar image Fattie · Mar 21, 2013 at 01:06 PM 0
Share

Just TBC, Gamer

Were you aware you can run your app

WITH NO STATUS BAR ?

indeed, on iOS most games run with no status bar.

To try to help, can you explain more why you even want a status bar?

Don't forget that the status bar is added BY THE OPERATING SYSTE$$anonymous$$.

it is { impossible! }, for Unity or anyone, to decide what status bars (or other elements) may be added by either Apple or Android, in the future

I could take a screenshot of a galaxy tab for you and tell you "the bar thing on the bottom which Samsung adds is XYZ pixels" But it could change anytime

the OS operators are literally adding it on top

Again ........ if you wanna:

t is incredibly easy to turn off the statusbar, from Unity

http://docs.unity3d.com/Documentation/Components/class-PlayerSettings40.html

search down to "iOS", open the disclosure triangle, and search for "status"

you literally just tick one box and that is the end of it.

it's fair to say that almost all (all ???) games on iOS hide the status bar.

avatar image Radazen2 · Mar 21, 2013 at 03:04 PM 0
Share

It's not at all uncommon for casual games to keep the iOS/Android status bar visible. For example: Words with Friends. It's a casual game where the user may very well want to know what time it is, what their battery is at, what notifications are waiting, etc, while playing the game. That's the style of game I've been working on lately, and I guarantee you that users would appreciate being able to see the status bar there. This is not a crazy feature request; this is something that both the iOS and Android platforms recognize is a valuable feature, which is why they allow you to show or not show the status bar depending on what kind of app you're writing.

Out of curiosity, have you written a native app on either of those platforms? You're making it sound like some sort of unsolvable problem, when the reality is that both platforms have easy mechanisms for letting the developer know the size of the status bar so they can structure their UI appropriately. All we're asking is that Unity3D be able to use those mechanisms so we can write professional-quality apps that take advantage of OS-level features, which is what Unity is supposed to do.

avatar image Fattie · Mar 21, 2013 at 03:16 PM 0
Share

"It's not at all uncommon for casual games to keep the iOS/Android status bar visible. For example: Words with Friends." Fair enough - quite true. With Unity you think of 3D and Arcade games, but more and more it's used for let's say "casual" games as you describe. WWF could use Unity in the future! :)

Further yes, you're right that iOS has a call to get the status bar height in pt. But UNity can't know what sort of bars, etc, will be added by apple not to mention android in the futcha.

Per the original question: "if I run with the statusBar turned on I would expect the 1536 value to be smaller to account for the status bar height" I just can't agree with that, sorry. It would be annoying and ridiculous if Unity subtracted whacky OS overlays. It would make the situaion extremely confusing for 99.9^ of unity devs.

YES - as you say - it would be handy if Unity (or Prime31 or someone) made a convenience function that grabbed whatever today's status bar values are. For sure. You're right.

As I sed ..

"if your point is, Unity should make a convenience function, for iOS users (like me) that does that ... well, fair enough. Unfortunately it does not have that, so simply do the calculation yourself."

avatar image Radazen2 · Mar 21, 2013 at 03:28 PM 0
Share

Right. I guess my point is that the only way to provide robust support for the status bar is to interact with the native platform, and most of us aren't comfortable enough writing native plugins to do that ourselves, which is why it would be nice if the functionality was included in Unity.

Show more comments
avatar image
2

Answer by Graham-Dunnett · Nov 25, 2012 at 10:18 PM

What fattie said.

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

14 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

Related Questions

how to get a window bigger than screen 0 Answers

Fixing the camera's left side in a 2D Game in all screen resolutions 0 Answers

Minimum resolution fix? [Solved] 0 Answers

AutoScale Screen with Perspective Camera 0 Answers

Can I customize the resolution window that appears at the start of my executable? 2 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