- Home /
2D Camera Size VS Screen Resolution
Hi,
I'm making a 2D game. It is almost complete. However, when I run it on different devices, the offsets of certain gameobjects are messed up due to the different screen size. In the Unity editor, I'm using the free aspect view, and I've created my gameobjects so that with a camera size of 80, they all align perfectly. I think the problem here is that the screen resolution messes up the display, and because I'm using a fixed amount of Unity units to position my gameobjects, they are displayed weirdly when I run the game on the standalone. I've written a pixel perfect camera script, but it doesn't seem to help. The camera is pixel perfect, however, in order to compensate, the camera size is turned into something extremely small, or extremely large. I just want the same look across all devices and screen resolutions. A main problem here is that I want my GUI elements to display next to where the player is standing. My script is here.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class HoldTimeMultiplierPlayerFollowController : MonoBehaviour {
public float textYOffset = 50f;
public Text holdTimeMultiplierDisplay;
void Update() {
Vector3 position = Camera.main.WorldToScreenPoint(transform.position);
holdTimeMultiplierDisplay.gameObject.transform.position = new Vector3(position.x, position.y + textYOffset, position.z);
}
}
Anyone got any ideas?
BTW,
all my art is 32x32. The pixels to units ratio is always 1 to 1. The camera size in the editor is 81.92, when I'm using a free aspect screen size of 686x269. At those measurements, everything is displayed perfectly.
Your answer
![](https://koobas.hobune.stream/wayback/20220611232711im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Scale Everything In Game to Fit all screen Sizes 1 Answer
How can I fix the screen disturbance of android 4.1/4.2 ? 0 Answers
How to make camera position relative to a specific target. 1 Answer
make the camera always match the resolution 1 Answer
How to Adjust Size of objects/Camera's size for different resolutions 1 Answer