I've read that the best way to keep a 1:1 sprite ratio for pixel-perfect art is to "set an orthographic size that matches the vertical screen resolution divided by the pixel height of a sprite" and then to halve that number to set as the orthographic size. For testing purposes I'm using my current monitor which is 1680x1050 and my sprites are 80x80, so (1050 / 80) / 2 = 6.5625 right? But when I set my orthographic size to 6.5625 this and test it full screen, the sprites are always smaller than they should be. What am I doing wrong? Source for the information: http://www.third-helix.com/2012/02/05/making-2d-games-with-unity.html
I'm not sure if this is what you're looking for, but I've been using this script (from a tutorial on YouTube) and it seems to do the job. Code (CSharp): using UnityEngine; [ExecuteInEditMode] public class ScreenController : MonoBehaviour { public int TargetWidth = 1440; public int PixelsToUnits = 32; private Camera owner; void Start() { owner = GetComponent<Camera>(); } void Update() { int height = Mathf.RoundToInt(TargetWidth / (float)Screen.width * Screen.height); owner.orthographicSize = height / PixelsToUnits / 2; } }
I applied that script to the camera but nothing happens (I played around with the numbers and noticed no changes) and despite there being no errors, I get this message below the script in Unity: The associated script can not be loaded. Please fix any compile errors and assign a valid script. EDIT: I'm not sure why it wasn't working before, but trying your code and then reverting back to the code I had before has somehow fixed it! Works great now, this is what I'm using: Code (CSharp): using UnityEngine; using System.Collections; public class CameraFollow : MonoBehaviour { public Transform target; Camera mycam; // Use this for initialization void Start () { mycam = GetComponent<Camera> (); } // Update is called once per frame void Update () { mycam.orthographicSize = (Screen.height / 100f) / 2f; } }