I’m Jay and I’m very new to both programming and Unity.
Background notes:
I have a very specific need.
I am trying to code a FrontEnd for an arcade cabinet.
I did it using Qt but ran into a big problem: so far I wasn’t able to port the code to the windows XP running my arcade cab. So basically the program/app did everything it should, but I can’t use it because of porting problems → back to square one, finding another technology/dev tools and redo the whole thing.
The things that I CANNOT change:
a) The program/app will HAVE to run on windows XP.
b) The program/app will HAVE to run at a 640x240 resolution (meaning ultra low rez).
c) The program/app will HAVE to be pixel perfect.
I’ve spent nearly 4 years working on all the sprites and design. Everything is set and coherent, everything is pixel perfect, I just need to “display stuff like backgrounds and sprites” and “play some animation loops” with just a little bit of scripting behaviour basically.
I won’t go into details about the other reason why (a) and (b) because it’ll be a long and painful talk, I’ll just ask you to trust me that these are the top priorities requirement and they simply cannot change.
Before I move/work into further understanding how UNITY behaves, I’d like to know if this tool COULD be the right tool for me. I have limited time, as everyone I guess, and I lack the perspective and knowledge to produce an advised answer :(. So if you think this tool can achieve that, or can’t for that matter, please do let me know : )
Camera Size = (GameTargetHeight / 2) / PixelsToUnits
Assuming that your sprites are something like 16x16 w,h respectively and pixels per unit for each sprite is 16, then
Camera Size = (240 / 2) / 16.
If you wanted to do it via script: (Create a new C# script: PixelPerfectSprites.cs and drag to your main camera)
NOTE: You will need to set pixels per unit for your spites (16 is what is assumed below)
using UnityEngine;
using UnityEngine;
using System.Collections;
[RequireComponent (typeof(Camera))]
public class PixelPerfectSprites : MonoBehaviour {
public int spriteWidth = 16;
public int screenHeight = 240;
// Use this for initialization
void Start () {
this.GetComponent<Camera>().orthographicSize = ((float)screenHeight / 2.0f) / (float)spriteWidth;
}
}
Alternatively, because you are always using a fixed resolution, you could simply set the size on an orthographic camera.
Second thread on a similar subject, lots of people wanting pixel perfect games eh?
I’ve made a tumblr blog post explaining how I implemented pixel perfection in my game, and just exactly what you’re asking. The game is rendered at a base resolution, for you it will be 640 x 240, mine is 640 x 480. Then the image is sent onto a second camera, and thats what the player will actually see, essentially game is always at this resolution, no matter what the window size is, fullscreen or not.