Fixed camera width instead of height? - unity3d

Is it possible to keep the camera width fixed instead of the default setting: height?
Making the height fixed is causing problems for my mobile game (vertical) on multiple devices. Is it possible to change this behavior of the camera?
Thanks

This has to do with the different aspect ratios. I don't think there is a fixed height, the screen just adopts to the given ratio.
If you want to achieve a fixed aspect ratio this unify page will probably help you, it will fill the screen with black bars of devices not fitting your ratio:
http://wiki.unity3d.com/index.php?title=AspectRatioEnforcer

Related

How to scale unity UI for every device

I'm trying to make a level select screen for my game, but when testing the game build the ui isn't scaled that well
I'm currently using the Canvas Scaler with the following settings
These settings give me..interesting results to say the least
What the result is SUPPOSED to be is this
How am I able to do this?
There a few things that you should keep in mind while building the UI for different screens.
Have a target Aspect ratio. Generally it should be 16:9 for landscape and 9:16 for Portrait.
Make sure the reference resolution is in line with your target aspect ratio.
Set the Match option of canvas scalar to 0.5 to scale evenly. If you are sure the device aspect ratio will change in only one direction then set either height or width. For example a portrait game will scale only by height if you switch from 9:16 to 9:18.(0.5 has worked always for me)
Select the aspect ratio in the game window and set the Anchors of the UI to the corner of the UI element. That way Unity will know where the element should be based on Canvas size.
Here is a video that demonstrates it
https://youtu.be/08S1VGL9afg
First of all, use some custom resolution in game view instead of Free Aspect.
Then you could try adjusting Match with Height or width to 0.5.
In some case, you have to adjust custom anchors using these little guys
If you want to absolutely preserve aspects, use this option on Image component.

How do I make my 2D game responsive to different resolutions?

I making a 2D game in unity. And I want to make my game responsive to different resolutions, and when I use Canvas Scaler all my UI objects become very bigger.
if you can help please response.
thank you!
Designing UI for Multiple Resolutions
1. Using anchors to adapt to different aspect ratios
One way to keep buttons inside the screen is to anchor them to their respective corners,
One way to keep the buttons inside the screen is to change the layout such that the locations of the buttons are tied to their respective corners of the screen.
Once the buttons have been anchored to their respective corners, they stick to them when changing the resolution to a different aspect ratio.
When the screen size is changed to a larger or smaller resolution, the buttons will also remain anchored to their respective corners. However, since they keep their original size as specified in pixels, they may take up a larger or smaller proportion of the screen.
2. Scaling with Screen Size
In the Canvas Scaler component, you can set its UI Scale Mode to Scale With Screen Size. With this scale mode you can specify a resolution to use as reference. If the current screen resolution is smaller or larger than this reference resolution, the scale factor of the Canvas is set accordingly, so all the UI elements are scaled up or down together with the screen resolution.
The layouts will appear the same in different resolutions, only with a lower pixel density depending on if you scale up or down.
One thing to be aware of: It can be possible that some element are larger in landscape aspect ratio. This can be fixed if you change the Match property to 0.5 instead, it will compare both the current width to the reference width and the current height to the reference height now.
Unity Documentation

cocos2d-x FIXED_WIDTH isn't working

I have a 700x1280 image and my design resolution is 700x1280.
I am not providing separate assets for each device that I target rather i will use one Resource which contains all my assets.
The problem:
When I set my design resolution I pass a ResolutionPolicy::FIXED_WIDTH meaning from what I understand it will scale the width with no bordering but the height may be bordered. But all I see is a fixed width but the height of the image goes out of the screen i.e it's not making the height fit in the screen like FIXED_WIDTH is supposed to do?
FIXED_WIDTH only promises to keep the width using the full physical width of the screen but doesn't promise that the height will stay the same i.e it may go out of the screen. For portrait mode FIXED_HEIGHT is the way to go because your height on any device is definitely bigger than that of the width so by using FIXED_HEIGHT the width will never go out of screen, it's a bummer but that's what you have to do!

Gaps or bleeding between tiles when using Tiled2Unity

I am seeing gaps or bleeding between my tiles when exporting from Tiled2Unity into Unity itself. What can I do to fix this?
This is probably because your game tab's aspect ratio has a fractional number of pixels for width or height. Click on the resolution in the top of the Game tab (it probably says Free Aspect or 4:3 or something) and click on the plus on the bottom to add a new aspect ratio.
Type an exact number of pixels for width and height and you will force the aspect ratio to always have a whole number of pixels. The bleeding will go away.

Unity3D: Aspect ratio issue

In Unity3D I can't scale the game properly to remove the black bar.
I've added pictures for reference:
EDIT: I need to make the canvas scale to the whole screen instead of only a part of the screen.
You should first set your game viewport to simulate the resolution and screen size of whatever you're building for. Change Free Aspect to the appropriate aspect ratio or manually add a new resolution.
Also, I believe the match mode you want for your Canvas Scaler is Match Width or Height.
You have to set anchors of Image to each corner of your canvas display so It can scale accordingly.
Just change the aspect ratio from 'free aspect' to '16:9' or manually enter an aspect ratio that suits your needs.
Cheers.
Try to dynamically spawn the background or image by using Scale To Fit lots of Unity Documentation to help with that so when compiled you can tend to get a stronger and fuller picture this may help with a general sizing issue
Set the screen resolution manually in the Start() of your code:
Screen.SetResolution(x, y, true)