Unity - Multi-resolution support strategies for 2d games - unity3d

I am trying to target a wide range of resolutions for a 2d titles we are starting to work on with Unity. I previously worked with different middlewares and I am trying to achieve something like the 'Fixed Height' strategy that can be found in Cocos2D-X (http://www.cocos2d-x.org/wiki/Multi_resolution_support).
I would like to know, in your opinion, what would be the easiest way to support a wide range of resolutions and display ratios using a minimum of different graphical assets with Unity 4.3 for a 2d title.
Thanks

If you could not use UGUI, you can select NGUI or other GUI engines. NGUI support fixed resolution with UIRoot. For examples, you can setup scaling style to Constrained on mobiles, content with to 960 fit, content height to 640 fit in UIRoot.
Otherwise, if you can select UGUI, you can use more flexible methods like Canvas Scaler, Rect transform.

Related

Scaling and positioning of parallax layers

I'm implementing a parallax background for my 2d side-scrolling game with Flame, similar to the example.
The ParallaxComponent api seems to support only placing layers using Alignment which puts them to the top/center/bottom of the screen.
I wonder if there's a way to position layers more precisely and change their size. Thanks!
The API of ParallaxComponent doesn't support this yet, but what you could do is using multiple ParallaxComponents on top of each other since they are PositionComponents that you can place and size as you like.

How do i fix the layout problem in unity?

Im trying to build a replica of the game 'Breakout'.
when i build and run the game in unity it looks good and everything id the correct scale but when i build and run the project on my laptop all the elements change size and some of the elements dont change size and i am not sure if i have done anything wrong or if i have forgotten to do something to stop it from changing.
This is what the game looks like in the unity editor when playing the game:
And this is what it looks like once i build and run the project on my computer:
My resolution is set to stand alone.
is there a way to get it to look like it does in the unity editor when i build and run it on my computer because that is what its supposed to look like.
These days, there are many different screen sizes, and resolutions.
My favorite solution is to use a reference resolution that can expand but never shrink. This allows you to have a safe zone that stays consistent across different screen sizes. For a generic case, you would use 16:9 aspect ratio, with the resolution of either 1280x720 or 1920x1080.
In Unity, on your canvas, modify the Canvas Scaler such that UI Scale Mode is set to Scale with Screen Size. Add your reference resolution, and set the Screen Match Mode to Expand.
In the Game tab you can preview what 16:9 looks like. You can try out other aspect ratios or resolutions.
For example, the iPhone 11 has a much wider resolution, so it expands horizontally. It's up to you to design your UI in a way that makes sense. You can either keep everything in the safe zone or align elements to the corners of the screen.

How to make responsible camera for multiplie resolutions?

I m working and some 2d game for mobile phones relate to chess, and I have a trouble with show board for different resolutions of mobile screens.
Here u can see how it must be on 9:16 resolution:
https://drive.google.com/open?id=1MFt-FtEtqkk7QWQC2oAtMBA0WAgOIV4h
And how it looks on smaller screen:
https://drive.google.com/open?id=11WLYZwHEa9ijXbekzUbE5ZbjbEnjZ6Lb
How can I protect my chess board from cropping?
Answer: it depends on how you want it to look.
If you just want it to fit perfectly horizontally, you need to perform 3 steps:
Evaluate the width of the Sprite (with Sprite.bounds)
Evaluate the width of the current screen (with Screen.width and using the main Camera)
Scale the Sprite to fit the screen
If you are using UI elements, you can do the same thing but you won't need to use Camera, just scaling according to the Screen width (look for RectTransform.deltaSize to give you the size of a UI element).
If you are using UI, also consider using layout groups, they help you with fitting the content to screen size.
Anyway, in a device with small width, maybe the table will get too small and you might have to think about better options to display the board instead of just scaling with screen width.

Textmesh - Pixelperfect

I'm want to create pixel perfect text meshes using unity's built in 3d textmesh, without using any other plugins. Since dynamic text is texture based as well, there should be a ratio between font size, text size and orthogonal camera size to make it pixel perfect.
I know that its not possible to make built-in 3d textmesh pixel perfect for perspective cameras since text size (and texture atlas size) will be effected from the perspective scale; however for orthogonal cameras that should be possible.
Online sources does not state the connection between the ratios I mentioned above; most of the people I've spoken do not really care about making text pixel perfect. However I do think it's very important especially if dynamic text is going to be used in a 2d game, and needs to fit to screen pixels.
If it needs to be pixel perfect, the only solution would be to use GUI text. If, however, you expect to animate it in a way that can't be done with OnGUI, or intend to partially cover the text with another object, I would recommend cranking up the font size, and the scale down. This will at least make the text very sharp, making it appear pixel perfect. I have used a font size = 100 and scale = 0.05 for x y and z in a 2D game to achieve a very clear and easy to read font.

Dynamically create sprite images for Cocos2d-iPhone

I'm working on a platformer, and looking for a way to create a sprite for an arbitrarily sized platform. For example, I may know I have a platform that should appear 200 pixels wide by 32 pixels high, and, say, I have a texture of bricks that I can tile to fill that area. I may also want to draw a black border around the platform. Is this possible at all? Anyone have any ideas for how I might go about doing this? I could always try generating the image on the fly and building a sprite with that image, but I sincerely doubt (hope) that this isn't the most efficient way of doing something like this.
Cheers,
Alex
You can use tiled maps for the platform. It will require you to plan your textures a bit differently, but it will probably yield better results.
You can read more about tiled maps here.