I am developing an Android/iOS application which will always be viewed in the "horizontal left" orientation. Originally I was developing on Unity 2019.2.9f1, but switched to 2019.2.14f1 when I encountered this issue. Sadly it is present on both engine versions.
I am using a world space canvas, and previously it was displaying and building fine for all aspect ratios. Previously I had over a dozen aspect ratio options, which you can see here:
However, they have recently all vanished, leaving only these:
When I select Free Aspect, the scene is visible as seen below, which is correct:
However, when I try and display on the desired "PhoneHorizontal" aspect ratio, you can see that it is extremely zoomed in and pixelated. When I zoom out to 1x instead of 52x, the scene is obviously extremely small.
Could it be that something in my project settings that is causing this? I thought the engine itself was bugged, but reinstalling a new version did not fix it. I do not know what originally led to this change. I have looked at my build settings and my players settings and they all seem fine. There is nothing in my code that affects the aspect ratio or display settings.
Edit: I have confirmed that this problem only exists when the platform is set to Android. This issue is not present for iOS. In addition, it is only present in the editor, not when I build to my device.
As I see in your screenshot. You are setting the resolution of GameView to 16x10 not the aspect ratio. You can check that in format how is that displayed.
Aspect ration uses :
Resolution uses x
So
16:9 is an aspect ratio
16x9 is a resolution of GameView
Related
I've Unity Plus and I'm trying to find out the optimum android splash screen size that fits all android devices as there's no option to specify multiple images with different resolutions for android.
So far I've tried 768x1024, 1536x2048 on every option(center, fill, fit), however some nexus tablets/phones won't display the splash image full screen correctly.
Is there an optimum/suggested image resolution/configuration for android devices that most likely fit all?
There is a Splash Scaling property in Player Settings for Android builds. Try setting it to Scale to fill (cropped). Your splash image will be scaled without changing the aspect ratio.
We are using 1280x720 image in Unity 5.3.4 for android builds without any problem.
The image will be cropped but if there is not any sensitive text or symbol on the edges that will not be a problem.
Hope this helps.
Generally, you'll want to include multiple copies of the image at different resolutions and aspect ratios in your deployment. For example, small and large, both with different ARs. You would read the screensize of the device and select the appropriate size image for the device.
To give more detail here, I worked on a game that targeted devices from small screen sizes (Galaxy Ace), to large tablets (Galaxy Note 10.1). We used our own splash screen implementation rather than unity's, and we calculated the aspect ratio of the device. We then checked the screen resolution. After that, we had enough info to select the appropriate resolution image for the screen. It costs a bit more space, but it looks nice and crisp on almost every device.
I am newbie to Unity 2D and creating a game in it. I wanted to run that game on almost all devices (Android, iOS, Mac, Windows and web. I am bit curious to see how Unity2D will handle this scenario and give the same user experience on various devices.
Also I noticed that I can preview my game in different aspect ratios. Is it the aspect ratio of the screen (like how the game would look on this type of screen) or of the camera (would look the same on all screens)? Do I need to provide different image resources based on the device's resolution?
Should I do something special to allow support for different resolutions, aspect ratios, etc?
Any help will be appreciated.
Aspect ratio management is explained in the following blog post: http://2sa-studio.blogspot.com/2015/01/handling-aspect-ratio-in-unity2d.html
Basically the orthographic camera has a size parameter which defines the half-height of the world area which will be rendered on screen.
Unity strategy is: fit rendered area height to screen height. Then the visible width varies depending on the screen ratio.
I'm developing a 2D puzzle like game. I want to target all iOS devices (iphone 4+ ,ipad 2+ and retinas) and as much android devices as possible. The problem is as you already guessed with resolutions and aspect ratios. How to deal with it, and what are the best practices. please share your experience and best approaches with this problem. My approach is , I'm building for 3:4 (the game is in portrait mode) aspect ratio with ipad retina resolution images and using orthographic camera. for different aspect ratios i resize orthographic camera , and as expected I get black bars at the top and bottom . aka pillarbox. so I'll just resize (scale Y) the main scene. (drop everything in an empty gameObject and scale it up). or add 2nd camera to deal with this black bars. But I need the best and the most correct way to deal with this problem , what's the best practices for 2D game development when targeting multiple resolutions,aspect ratios. I've searched the net and forum but couldn't find the CORRECT WAY.
I have an app that I am working on that makes use of the front-facing camera on the device. I am trying to set the preview size by getting the list of supported preview sizes and looping through them looking for one that is pretty close. The method that I wrote to do so is basically the same as the one from the OS's own camera app. The method works fine, exactly how I would like it to, that's not why I am here.
I was having problems with the camera preview looking obviously skewed on some devices; either squishing or stretching the preview of the image. I couldn't figure out why it was doing this so I stepped through it and looked at all of the supported preview sizes available to my front-facing camera and found that there were only 2 and neither of them were the correct aspect to be usable. My "surfaceChanged" method in my SurfaceHolder.Callback class is reporting a width and height of 762x480 for the front-facing camera, but of the two supported preview sizes (acquired with cam.getParameters().getSupportedPreviewSizes()) both were in the opposite aspect: 480x800, 320x640.
With these as the only options, it seems impossible to have a preview for my front-facing camera that is not skewed. I know that in versions 2.3 or less, arbitrary values can be used for width and height without regard to supported sizes, but I am trying to make my app work for newer versions of the OS as well. How can I make the preview look correct?
My initial question remains technically unsolved (and I still believe it to be impossible) however I did figure out the trick to a non-skewed preview.
Given the supported preview sizes all being in the incorrect orientation compared to my device's screen it does indeed seem impossible to have a normal preview that fills the entire screen. After looking at several native camera apps on different devices (all of which that display the front-facing preview with no skewing at all) I noticed that very few of the devices (only one, in fact, and that one had a non-standard screen size) had previews that covered the entire screen as I was attempting to do in my app.
I reworked my app to get the size with the closest width and height to the device screen, but without going over in either dimension or in aspect ratio, and then manually set the height and width of the SurfaceView to match the selected size. True there is a small amount of black space around the preview on some devices now, but it definitely looks much better than being skewed. I had a panel with buttons for snapping a picture and manipulating flash settings, etc. on one side anyways, so it really is less noticeable than one might think.
I have a camera app, in it's simplest state it's nothing more then the cameraPreview example with some 'takePicture' code. The link to the example online is for 2.0, and i'm developping against 1.5 (API lvl 3), but still, here it is: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/CameraPreview.html
The biggest difference with the old version is the whole "getOptimalPreviewSize" thing.
Everything is done landscape.
Now the problem is: i have a preview, but when i take the picture there is more information on that picture then there is on the preview. The top and bottom show stuff that wasn't visible on the preview.
Now i am going to put an overlay on top of the preview, to align the object in the picture with something. If the picture is taken, the whole thing gets squeezed a bit, and i'm all out of alignment :(.
The camera app on the system doesn't have this problem, so it must be possible to fix this. Any thoughts?
If i must manually set the preview and/or picture size, i'll have trouble with different handsets i guess, and because there are a lot of function only since API lvl 5 (e.g.: getOptimalPreviewSize), I can't use these.
Having built a custom camera app for Android, I know exactly what you are going through. Android 1.5 makes up only 1.1% of the Android users as of 10/29/2011. You will be better off jumping up to at least API level 5. If you want to support portrait and landscape previews consistently on all devices, I recommend you go even higher.
Make use of the getSupportedPreviewSizes() and getSupportedPicturesSizes(). These functions tell you exactly what the camera supports (varies by phone/manufacturer). Run through the enumerations and find values that match from both. Use the one that suits you best.
Word of warning: Failure to set preview and picture sizes that are actually supported can cause your app to crash on certain devices. I've seen this first hand.
reference to 1.5 Android users
The largest preview size returned by getSupportedPicturSizes represents the native resolution of your camera. If the aspect ratio of that size differs from your preview size or the picture size that you set your Camera object to then then cropping will occur. You can compare the aspect ratios to determine how much will be cropped and in which direction.(top/bottom vs left/right)