Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: NianDarck on November 07, 2012, 12:34:13 PM

Title: Resolution switch problems on iPhone and iPad
Post by: NianDarck on November 07, 2012, 12:34:13 PM
we are doing a test in landscape mode in the ipad and the iphone, our image is set to: 1024x1024, if i put the manual height to 480 it almost look good (excellent on iphone but in ipad looks a little moved), but if i put the manual height to 1024 or 768 it looks alot smaller, why is that?, and what settings I have to change in the manual height?
Title: Re: Resolution switch problems on iPhone and iPad
Post by: ArenMook on November 07, 2012, 02:32:42 PM
If you want it to look the same, don't change the manual height.
Title: Re: Resolution switch problems on iPhone and iPad
Post by: NianDarck on November 07, 2012, 03:00:25 PM
thanks for the quick respond :D, now we have the manual height always to 480, but the problem now is that in the ipad3gen the GUI is look really small and in the ipad1gen and ipad2gen still moved to the left and some of the GUI its not displayed because of that problem, also in ipad3gen we have a highres texture (2048x2048) insted of the low res (1024x1024). What do we have to do so the GUI does not look smaller in the ipad3gen and don“t look moved to the left in the ipad1gen and ipad2gen?
Title: Re: Resolution switch problems on iPhone and iPad
Post by: ArenMook on November 07, 2012, 05:12:28 PM
Not sure why it would move to the left? You might want to look at your anchor setup. Try building the provided examples for different devices. Open up the first one (anchor example), change its UIRoot to use a manual height of 768, and try building that, for example.
Title: Re: Resolution switch problems on iPhone and iPad
Post by: Nicki on November 08, 2012, 01:41:06 PM
Ipad3 looks really small, because UIRoot has a default maximum height of 1024, and that checks actual screen.height, and when that's higher than 1024 it sets your manual height to that.

Check your UIRoot, it will be set to 1024.

Set the maximum height to 1000000. Then it's fine.
Title: Re: Resolution switch problems on iPhone and iPad
Post by: ArenMook on November 08, 2012, 02:04:18 PM
That will make it look smaller, Nicki. :P
Title: Re: Resolution switch problems on iPhone and iPad
Post by: Nicki on November 08, 2012, 04:03:23 PM
No it won't, since Screen.height is smaller than 100000. It only gets set to that, if the Screen.height (not UIRoot's Manualheight) is bigger.

He should, obviously, keep his manual height at the 480 he put it.

I actually think it's a bug - or at least it's sorta weird behavior, that it changes it to maximum even if you set manualHeight to lower than that.
Title: Re: Resolution switch problems on iPhone and iPad
Post by: ArenMook on November 09, 2012, 04:54:24 AM
The way it works is -- if the Screen.height is between min and max, the UIRoot's is treated as if there is no min/max, and the root is set to "automatic".

If the Screen.height is not within the min/max range, then the UIRoot is treated as if it's not automatic, and the manual height is Mathf.Clamp(Screen.height, min, max).
Title: Re: Resolution switch problems on iPhone and iPad
Post by: Nicki on November 09, 2012, 05:13:58 AM
It also does it if automatic is unchecked (set to manual height),  and that's exactly what's happening.

The default values of min max are something in the order of (320, 1024) and when ipad 3 comes along with a screen.height of 2048, it clamps to 1024 instead of the inspector set manualheight of 480 (or whatever number you used).

Setting the max to be higher than your screen height will ever be will "fix" the problem.

We had the exact same problem for the Nexus 10 and Ipad3.

I would argue that when you set a manual height, you don't need to clamp the activeHeight, since it should be the NGI user's responsibility to handle it. But in any case, that's what happening.

Look in UIRoot.cs under public int activeHeight, and you can see the reason.

:)
Title: Re: Resolution switch problems on iPhone and iPad
Post by: maik on December 13, 2012, 07:42:11 PM
Hi,

I'm on the same team as niandarck.

We solved the problem a while ago, and the way we solved it was:

Go back to version 2.1.2
(we originally created the GUI with 2.1.2, and everything fine. Then we updated to 2.2.3 and then the problems came)

Just by doing that, with exactly the same settings, the same elements, now everything works fine.

But if we upgrade, the problems comes back (not all the positions are respected on the different devices).

The main problem here is: we want to use some of the new features of newer versions...  What can we do about it?
Title: Re: Resolution switch problems on iPhone and iPad
Post by: ArenMook on December 14, 2012, 12:10:17 AM
If you have the Pro version you can simply pick which changes you want by merging them into your repository selectively. If you don't have pro, then you have to do it all manually.
Title: Re: Resolution switch problems on iPhone and iPad
Post by: maik on December 19, 2012, 01:12:54 PM
But how can we know which features breaks the compatibility?
In the release notes does not say anything about it.
Title: Re: Resolution switch problems on iPhone and iPad
Post by: ArenMook on December 20, 2012, 01:20:44 AM
Compatibility with what? Generally if there are some compatibility issues, such as going from Unity 3 to Unity 4, it's #ifdef'd -- which is quite obvious.
Title: Re: Resolution switch problems on iPhone and iPad
Post by: Nicki on December 20, 2012, 04:12:30 PM
Maik, in general you want to be at the newest version - if there's something that genuinely breaks in the NGUI code, make a simple case that reproduces the bug and send it to ArenMook at support at tasharen.com as a zip or something like that, and he'll fix it.

Often it's your own custom code interacting with the NGUI code oddly in my experience, but not always. :)
Title: Re: Resolution switch problems on iPhone and iPad
Post by: PapaWhiskey on December 22, 2012, 12:41:48 PM
contemplating switching to NGUI from UIToolkit due to issues with scaling for aspect and resolution (both of which are doable in UIToolkit, just not reliably for one reason or another)...

theoretically NGUI handles multiple resolutions from what Ive seen in the forums, yet downloading the eval version and running the UIAnchor scene, it's obvious that resolution is not solved...as supplied changing the resolution on the UIAnchor sample while the build settings are set to Android, shows that there are still issues with multiple resolutions.

From browsing the forums it sounds like maintaining aspect ratio is also not supported, unless i didnt dig through enough posts.

Does the resolution switching not work in the Editor? is it not working for that sample? Is aspect ratio scaling not supported natively? (meaning I have to do it in code)...can i easily set a global scale for NGUI?

Was out most of yesterday so I'll admit I didnt read "every" post in the forums, but myself and another programmer verified multiple times that the resolution switching did not work on the UIAnchor scene...is it possible (read "get latest" on one post) that the evaluation version is "behind" the main branch and thats why there are issues?

Phil
Title: Re: Resolution switch problems on iPhone and iPad
Post by: PapaWhiskey on December 22, 2012, 01:25:23 PM
and from what I can tell (yes i've had time to search the forums) the solutions lie within other users scripts that at some day may or may not be integrated into NGUI...

still disconcerting that the UIAnchor sample did not work "out of the box"...might want to update the eval version IMO.

Phil
Title: Re: Resolution switch problems on iPhone and iPad
Post by: ArenMook on December 23, 2012, 06:49:27 AM
Free version is pretty old -- from back in May. Everything should work in the full version.
Title: Re: Resolution switch problems on iPhone and iPad
Post by: PapaWhiskey on December 23, 2012, 11:18:02 AM
hmm...

went ahead and purchased on asset store this morning...imported into new unity project with nothing in it

uianchor is still not a poster child for resolution issues. while running, change resolution from 1280x800 to anything else, and portions of the ui are now cut off.

as mentioned yesterday, it seems the solution to resolution/aspect changes while using NGUI lie in using other developer scripts. I will try those upon return from holiday...either that or documentation needs an overhaul...i do recall one poster in the forums indicating that the naming of variables and their intended usage was counter-intuitive.

i bought it through the asset store, so i dont know if that will invalidate a refund if it turns out that NGUI is still not the solution for us. I will let you know privately after evaluation.
Title: Re: Resolution switch problems on iPhone and iPad
Post by: ArenMook on December 23, 2012, 06:33:18 PM
If your UI is getting cut off with UIAnchor used, then you are either not using it correctly, or are not quite grasping how to use it. If you post some pics of what gets cut off, I can give you some suggestions on how to fix it.
Title: Re: Resolution switch problems on iPhone and iPad
Post by: PapaWhiskey on January 04, 2013, 09:12:05 AM
back from holiday...sorry for the delay in reply

create new empty unity project
switch platform to android
set resolutuion to 1280x800
import ngui project
press play
switch resolution
top of background is cut off
change manual height, no effect
change max height, no effect
switch resolution back to 1280x800, still cut off.

as of others have stated since my last post, there is still an apparent need for clarity...links to the tutorials and the forums don't seem to be curing the problems folks are having...apologies in advance if you've already made a current tutorial and updated documentation for resolution issues.
Title: Re: Resolution switch problems on iPhone and iPad
Post by: ArenMook on January 04, 2013, 01:24:10 PM
Your game is paused. The UI won't be resized while it's paused. It must be actually playing.
Title: Re: Resolution switch problems on iPhone and iPad
Post by: PapaWhiskey on January 04, 2013, 01:31:32 PM
I paused to alt-tab to run the snip tool to take the screen grab...
Title: Re: Resolution switch problems on iPhone and iPad
Post by: PapaWhiskey on January 04, 2013, 02:00:13 PM
i notice you DID add a new video on the 24th...that shows a difference in our approach...you're manually resizing the game window to random resolutions...i'm using the actual resolution button on the game window to pick an actual Android resolution...but even saying that... i posted first, then went back and tried your approach of undocking the game window...it's still not behaving as in your video tutorial...maybe it's all just an editor thing that needs to be fixed? I'll try it today on my two devices...samsung galaxy s and nexus 7 tablet...
Title: Re: Resolution switch problems on iPhone and iPad
Post by: ArenMook on January 04, 2013, 08:19:07 PM
The game must be playing or you need to use Unity 4.1 in order for the UI to update after resizing the window.
Title: Re: Resolution switch problems on iPhone and iPad
Post by: PapaWhiskey on January 05, 2013, 07:48:37 AM
The game must be playing or you need to use Unity 4.1 in order for the UI to update after resizing the window.

I'm sorry, I thought I pointed out that I was running when making resolution switches...and is it now a requirement to be using Unity 4.x?
Title: Re: Resolution switch problems on iPhone and iPad
Post by: ArenMook on January 05, 2013, 07:50:51 AM
Nah, I simply changed Unity 4.1 to call update after screen size changes while in Edit mode, something Unity 4.0 and earlier don't do.

Keep in mind, switching the resolution via that drop-down may not actually give you the resolution you want, but simply change the aspect ratio (unless your actual window is large enough). Click the Stats button to see your actual window's size.
Title: Re: Resolution switch problems on iPhone and iPad
Post by: PapaWhiskey on January 05, 2013, 07:57:16 AM
good to know that we dont need to upgrade Unity. I use "maximize on play" and going from a 1280x800, which fits and draws as expected, and stats verifies, to a 480x320 should obviously fit...if it's just a refresh or update issue, we'll figure out away around it to make sure we still have WYSIWYG...if we find that it works on device, we can also just build the GUI at our "source scale" and trust it to work when deployed...
Title: Re: Resolution switch problems on iPhone and iPad
Post by: ArenMook on January 05, 2013, 08:15:25 AM
Well, I don't know what else to say, so I made a video.

http://www.tasharen.com/ngui/reschanges/
Title: Re: Resolution switch problems on iPhone and iPad
Post by: PapaWhiskey on January 05, 2013, 01:50:10 PM
appreciated...

to be fair to Tasharen, I don't doubt it works, and many are using it successfully.

However the supplied sample didn't "work", the tick boxes are not intuitive, alot of the answers are scattered throughout the forums, there is difference in how users use Unity and how Tasharen uses it, and there appears to be at times communication errors in the support forum...the video shows the anchor boxes work, as they did in the sample, it's the cutting off of the background that I've been focusing on, so if I failed to convey that, thats my fault, although I thought the screen capture I posted showed that was the thing I had an issue with...

thanks
Title: Re: Resolution switch problems on iPhone and iPad
Post by: ArenMook on January 05, 2013, 03:35:56 PM
Sounds like this may answer your questions: http://www.youtube.com/watch?v=XAeRXckXMMw
Title: Re: Resolution switch problems on iPhone and iPad
Post by: Tripwire on January 07, 2013, 02:55:01 PM
Sorry to Hijack this thread but i seem to have some problems with resolutions changing too. I have an App and the GUI is made for the iPhone 5 but has to be used for iPhone 4 and 3GS too. Now it scales the height but not the width :(

UIRoot settings:
Automatic = off
Manual Height = 1136
Minimum Height = 480
Maximum Height = 1136
Title: Re: Resolution switch problems on iPhone and iPad
Post by: PapaWhiskey on January 11, 2013, 12:03:03 PM
Sorry to Hijack this thread but i seem to have some problems with resolutions changing too. I have an App and the GUI is made for the iPhone 5 but has to be used for iPhone 4 and 3GS too. Now it scales the height but not the width :(

UIRoot settings:
Automatic = off
Manual Height = 1136
Minimum Height = 480
Maximum Height = 1136

I still don't have 100% concrete answers on this, after watching too many videos, reading too many forum posts, trying ratioFix scripts, etc....

so lets try a simple q&a...

say you use one atlas for all resolutions...you design your UI at a "middle ground" resolution., for this example lets say..720x1280 (portrait)

we have three variables and a tick box to muck with
automatic off (seems to be what most folks want for this problem)
manual height = ? (the height of the original ui design resolution? 1280 in this example?)
min height = ? (the minimum targeted device height?)
max height = ? (the maximum targeted device height?)

should you adjust manual height at runtime when the resolution height is not 1280? (the original ui design height).
should you only adjust manual height to match the original UI design (if you had SD/HD atlas...you'd change the manual height when you change atlas?)
Title: Re: Resolution switch problems on iPhone and iPad
Post by: ArenMook on January 11, 2013, 01:19:05 PM
If the 'automatic' checkbox is off, min/max values do nothing. They are only used to restrict the automatically scaled UIRoot. In your case, set the height to a manual value of 1280 and design your UI. No need to adjust anything afterwards.

If, however, you need things to be "glued" to sides of the screen at any point, you will want to do so by making your UI modular and using UIAnchors.
Title: Re: Resolution switch problems on iPhone and iPad
Post by: PapaWhiskey on January 11, 2013, 04:38:27 PM
If the 'automatic' checkbox is off, min/max values do nothing. They are only used to restrict the automatically scaled UIRoot. In your case, set the height to a manual value of 1280 and design your UI. No need to adjust anything afterwards.

If, however, you need things to be "glued" to sides of the screen at any point, you will want to do so by making your UI modular and using UIAnchors.

got it...

okay now a simple anchor question...should i put the anchored button/label/sprite as a child of the panel that has the center anchor? or should they be at the same level under their own anchor? (ala UIAnchor sample)...

what happens if you make a hierarchy of

UIRoot
  ->Camera
     ->Center Anchor
        ->Panel 1 (some window)
        ->Panel 2 (another window)
           ->Anchor BottomLeft
              ->Button

Title: Re: Resolution switch problems on iPhone and iPad
Post by: PapaWhiskey on January 11, 2013, 06:12:30 PM
also...back to one of my original issues...in the UIAnchor demo the "background" is under Anchor Center, yet when you run different resolutions (even in your video example) parts of the background get cut off...yes the 9 "edge" anchors work great...but the background that is on anchor center will lose data top/bot/lt/rt ...that is not acceptable if your bg is an integral part of the scene...whats the solution? I havent seen it yet in the forum (or i forgot it because i've read too many posts)
Title: Re: Resolution switch problems on iPhone and iPad
Post by: Nicki on January 11, 2013, 07:41:19 PM
It depends on how you are handling multiple resolutions.

If you are changing the Manualheight of UIRoot, you will have to adjust your background to use the new size of the "virtual pixels" that UIRoot provides in the local transform.

If you are using automatic, it should handle itself, I believe, unless of course you change aspect, which you also will have to take into account yourself. Ipad - iphone are obvious examples of two different aspects.
Title: Re: Resolution switch problems on iPhone and iPad
Post by: ArenMook on January 11, 2013, 08:03:39 PM
Anchors should be above panels, ideally.

UIRoot
  ->Camera
     ->Center Anchor
        ->Panel 1 (some window)
     ->BottomLeft Anchor
        ->Panel 2 (another window)
           ->Button