- Home /
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?
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.
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.
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.
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?).
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.
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 !
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.
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.
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.
"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."
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.
Your answer
Follow this Question
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