How can we create sprite renders that will fit all resolutions…That is in different mobile devices.I know that Canvas Helps with anchoring property.But Sprite Renders do not have this.So what to do??
Just create Your game object. Unity do this automaticly for You. You could change resolutions in Your editor to check behaviour. So canvases need additional component named CanvasScaler, but normal GameObjects not.
The canvas is designed for UI elements. Sprites that are not used as part of a UI element are simply other GameObjects. Can you tell us more snout what it us that you are trying to do?
if i placed a gameobject at left end in iphone ,it should be on the left end if i select ipad screen…but sadly it is not
This is a long explanation, but may - in some way - help you understand part of the issue.
I’d suggest giving that a read and then posting here more about your game.
First of all I need to tell You @mathewsbabu that I was wrong when I answered you. I thought about scaling within the same ration. About Your question - yesterday I had the same problem but I almost sure that I solved it.
Fast look → I have game with many tiles. I want to have 10 tiles from left to right. The same number of tiles in different resolutions and no extra empty spaces on left and right. I had a good look for one resolution but for other it was bad. Then I found in google some tricky way:
using UnityEngine;
using System.Collections;
public class CameraGameScript : MonoBehaviour {
public float orthographicSize = 454;
public float aspect = 0.648f;
// Use this for initialization
void Start () {
}
public void InitializeCameraProjectionMatrix()
{
Camera.main.projectionMatrix = Matrix4x4.Ortho(
-orthographicSize * aspect, orthographicSize * aspect,
-orthographicSize, orthographicSize,
camera.nearClipPlane, camera.farClipPlane);
}
}
Of course initialization is somewhere in my other script.
Now in all different resolutions I have 10 tiles exactly from left to right without any extra space. I can even run it landscape! (Everything is then very widely, but it is still exactly from left to right). Of course I adjusted these magic numbers. However, at the end of the day I do not know how it is working! @Adam-Buckner_1 do You know why I need to put these magic numbers? How it its working and why it is so easy to do this? Probably this way have some defects whose I do not know.
Thanks for the reply @Adam-Buckner_1 and @codeedward …Now am into some other stuffs…will let u know after checking this