Unity Standalone App: Resolution Scaling Issue (OSX) - unity3d

I have developed a Mac-OSX standalone app in Unity3D (Scale with Resolution: 1920x1080). Most of the time I present the app on my laptop, connected to an external screen, which works pretty well.
But when I'm on the road and use the app on my laptop screen (1440x900), the UI's are all over the place...
I know, BUT is there a way to run the app in a 16:9 ratio (with black bars on the top and bottom), the same as I can do it in the Unity3D editor?
I don't want to go back and re-scale everything to a lower resolution, as this would be a crazy job :(
Is there any solution without re-doing it?
Cheers

Thanks, but sadly this didn't work for me. The problem is my Reference Resolution in the Canvas Scaler is already set to 1920x1080. To fix this, I have to lower the reference, but this means re-doing all the UI's.
However, I found a workaround, which is strange but working. I have set the Default Screen Resolution in Unity to 1920x1080 as in the image/link below.
Now the strange part :)
1. Start the app with the option key on an HD screen and set the resolution to 1920x1080.
2. Save and Quit
3. Now the app is scaled down to 16:9 and keeps everything in place.
This works as long as you don't start this app or any other Unity build, with the option key on a lower resolution screen. In this case it will scale everything back again. You can redo the steps 1-3 and it will work again.
Not sure if there is another way to do this, but at least I have kind of a solution.
Default Screen Resolution in Unity to 1920x1080

There are two things you should check; 'Resolution and Presentation' under 'Player Settings', and canvas scalers. I have being in a situation similar to yours, I had built an iOS application meant for the vertical orientation, but also wanted to test it on macOS, the application launched correctly in fullscreen mode looking like this (The top status bar was intentionally brought down to show the aspect ratio):
Instead of using black bars on the sides, it seems like that Unity simply used the colour of the canvas of the current scene to fill in the gaps. This was my settings to get this result:
Only the 16:10 ratio (MacBook Pro) was checked, but the application functions in the iPhone's vertical ratio, I did not have to manually rescale the canvas,I simply switched the build platform, this was allowed by the canvas scalers I have added onto every canvas with the following setting (UI Scale mode: Scale with screen size | Screen match mode: expand), this would allow the canvas to expand automatically and scale to any aspect ratio, without messing up the UI:
Hope this Helps!

Related

Unity Build wrong aspect ratio in full screen

I've made a new 2D Unity Project in v2020.3.25f1 and set Fullscreen Mode to "Maximized Window".
When I build the app the whole screen is filled:
But when I exit full screen, reopen the app and switch back to full screen I get this:
Is this a bug? Is it caused by MacOS? It's driving me insane. ;(
Unity saves the last resolution you left the application at. If you left it at 800x600, next time you launch it it will be 800x600.
When you exit fullscreen, it makes the app another aspect ratio. When you re-launch it, it re-launches at the weird aspect ratio.
Solution Idea 1
You could enable resizable window, that will most likely be a quick solution.
Solution Idea 2
You could also force the game to be a certain resolution when the game starts.
Screen.SetResolution(WIDTH, HEIGHT, IS_FULLSCREEN);
So in your case, it would be (assuming your screen is 1080p)
Screen.SetResolution(1920, 1080, true);

UiButton don't size correctly with Canvas

I have a problem when I try to change screens , from iPhone X pro to iPhone 8 ( landscape mode). The button don't resize correctly when I make the change.What should I add to the Canva or buttons to get a better size.(Same issue for the panels)
CanvaInspector
ButtonInspector
First of all, if you want your application to just work in landscape mode, then you can set the Reference Resolution as X:1080 Y:1920, set the Match value as 1 (this is based on how you want your UI to react, so you may want to keep it as 0), set your preview screen size as 1920x1080 Landscape, and try to build your application based on that reference, it will make most of the things easier. Furthermore, if you anchor your UI elements properly, it will react to different resolutions without any problem. For the anchors and pivots, you may want to take a look at the unity documentation for basic layout.
However, if you want your application to work in both portrait and landscape mode, then the general idea is more or less the same, you may want to play with your reference resolution and match value (for example, setting the match value as 0.5 will make the UI resize by considering both height and width equally). This documentation can help you to understand it better.
I also know that some developers design different UIs for landscape and portrait mode separately and then activate/deactivate them based on the orientation of the phone. This can also be an option.

Cocos2d/Cocos2d-x Retina Issues

I have a multiplatform iOS/Android game that I programmed in Cocos2d-x. I have only one set of images to use (I'm only after high res devices) that get scaled according to the device's resolution. For example all images are for the iPad but if you are using a Galaxy S then the image locations and scaling are affected by GalaxyS_screenWidth/iPadscreenWidth.
This works fine for all Android devices and on iPad, iPad2 and old iPhones, but with Retina iPhone there is a problem. On the iPhone 4 all my images look extremely pixelated, a result from the images being scaled to iPhone non-retina resolution then scaled back up to fill the screen.
I tried enabling Retina Mode and the images are half of their intended size (maybe due to the usage of get winsize() which uses points) and scaling manually causes other sorts of problems. I tried playing with a lot of options and attributes but to no avail, so what should I do now?
EDIT:
This is not only a graphics issue, as text gets automatically scaled down then up and appears pixelated.
EDIT 2:
Fonts are bitmaps so my bad. But I don't want to use retina as all images are already retina by default. All of my images are set up for the iPad so for iPhone 4 I just scale them down a bit. This works with Android phones.
For example I have an image, depending on screen resolution obtained through getwinsize():
If current resolution width is 1024 then image stays the same.
If current resolution width is 900 then image gets scaled by 900/1024, no problem.
If device is iPhone 4 resolution width is 480, so image gets scaled by 480/1024, then cocos2d-x automatically scales the resulting image by 2 thus the pixelation. I tried using getwinsizeinpixels, I tried multiplying the screen size, I tried many things but nothing worked out of the box unless I am to redo many of my code.
So the question is, how can I just let the damn engine treat the iPhone 4 as an Android phone with resolution of 960x640?
If you want Retina resolution images to look like Retina resolution images, then those images need to be in Retina resolution (960x480).
If you first scale down the image to 480x320 and then upscale it on the device, it will of course look blurred. You can't magically make the Retina pixels appear from a lower resolution image by scaling it up.
SI couldn't get to the bottom of it so I employed a hack. I enabled Retina Display then I scaled everything x2 through code except for the text. Sounds stupid, but it worked, and pixelation is gone. Thanks everyone who spent time trying to help me.
I tried enabling Retina Mode and the images are half of their intended size
when you enable retina support, cocos2d gets images by appending #"-hd" to their provided filenames. Such images are meant to be double the "visual" size (in iOS terms, pixels vs. points), so that they can be sort of scaled down to make full use of device resolution.
If you have a look at the CCDirectorIOS class, you will find there a couple of methods dealing with this, especially those dealing with the scalingFactor. I don't know what kind of changes you should do to make it work, but if you step into those methods and look at the value of various objects, you might find a way to modify cocos2D default behavior for your specific case.
If this seems to complicated, one thing you could try is changing the CC_RETINA_DISPLAY_FILENAME_SUFFIX so that cocos2d will not look for specially-named files for the retina iPhone, but just use the normal ones.
For example all images are for the iPad but if you are using a Galaxy S then the image locations and scaling are affected by GalaxyS_screenWidth/iPadscreenWidth.
Another thing you might try is not using winSize, but winSizeInPixels, so that when you scale down, you down do it down to the point resolution, but just to the pixel resolution (which is double the point resolution).
Hope this helps.

how to disable retina image scaling in cocos2d-x framework

I'm porting my android game to osx I'm having problems on devices with retina display, the sprites are either unnececary scaled or the sprites offset are scaled and not in place, I'd like to have a possibility to control this by myself.
Is it possible to work in retina mode without scale factor, can I somehow enable usage of a full screen 960x640 and with scale factor still set to 1.0?
Could you please tell me how can I do it?
You can disable retinal display in AppDelegate.cpp file. In your didFinishLaunching set RetinaDisplay to false. :) Hope this works

iPhone game display is off the screen by 10 pixels or so on the device

I recently deployed my first iPhone app, a simple game, to my testing iPhone for the first time. Everything looks and runs fine on the simulator in Xcode, but on the iPhone the whole image is shifted up about 10 pixels or so. So the gameplay goes slightly offscreen on top and has a slim white/grey bar at the bottom. Has anyone encountered this before? I do have the status bar display turned off, I'm wondering if the device handles that flag differently than the simulator. I also have the rotation hardcoded to be in portraitRight mode at all times, and I have an extra line in the code to make the simulator do that automatically that's apparently not necessary on the device.
Everything is very simple, so I'm not sure where this glitch is coming from or even where to look.
Did you use Interface Builder to create your UI? If you did, then go and check each and every XIB file(s) objects' Size & Position as well as Autosizing in Size Inspector (command-3).
It's very important to check both: your coordinates might have gone wrong after some change you did and autoscaling works in weird ways unless you attach to correct edges. Apple documentation should help http://developer.apple.com/iphone/library/documentation/DeveloperTools/Conceptual/IB_UserGuide/Layout/Layout.html