Thanks for clarifying!
atamocius
Recent community posts
I have not tried this yet, but theoretically, if you are using pixel fonts and assuming that the camera that shows the render texture is orthographic, you can just "align" the pixels of the font to the render texture. Going with that, this can also work with any artwork. Doing so, the UI is in front of the render texture (assuming that the Canvas is set to "Screen Space - Camera")
EDIT: the other idea is if you are rendering your UI to the render texture as well, you could add trigger colliders to the render texture, but that can be tedious to setup especially if you have animated UI. A possible solution is to have static "hotspots" on the render texture, and just swap the UI that fits into those hotspots.
While I was digging around looking for similar setups, I came across PixelCamera2D. The approach is somewhat similar, though it is already packaged as a prefab.
Regarding the fixed resolution, I tried out Packer's Auto Resolution script and it works great. I just made a few tweaks. In the Update method, I also call the AutoScreenSize if Screen.width != Screen.height, and I have an IsPowerOfTwo method instead of checking for each height value. You can take a look at the code here. The code ensures pixel perfection; it changes the resolution to the next power of 2 smaller than the chosen resolution. It works for both windowed and fullscreen modes.
Regarding publishing, the only workaround I see so far is to target WebGL. You can use arbitrary resolutions for this.
EDIT: If deploying as Windows/Mac/Linux binary, you could just put some artwork on the extra spaces (this can be achieved as some background quad larger than the render quad). One could also use this area for on-screen controls if deploying to mobile devices. Perhaps making it look like the play area is inside an arcade cabinet?
Just use Unity's RenderTexture. Take a look at the example in the manual (near the bottom of the page).
You can quickly build on that process by using a Quad (GameObject -> 3D Object -> Quad) instead of a cube.
- Create a new RenderTexture asset
- Set the resolution to 64x64
- Set AA to none
- Set Filter Mode to Point
- Assign the RenderTexture to the "Target Texture" field of the Main Camera
- Create a Quad (GameObject -> 3D Object -> Quad)
- Turn off Cast & Receive shadows on the Mesh Renderer
- Drag the RenderTexture asset onto the Quad to use the RT as its material
- Change the shader on the Quad to use "Unlit/Texture"
- Create a new Camera
- Set this to Orthographic
- Set Size to 0.5 (assuming that the Quad is of unit size)
- Align the Camera to the Quad
- Create a new Layer
- Assign that new layer to the Quad
- Set the new camera to only render that layer
- Set the Main Camera to exclude rendering that layer
Tada! You got yourself a low res 64x64 setup in Unity. =D
Essentially the "Main Camera" captures all the gameplay, and the other camera will just render the Quad and nothing else. The only problem now is building a player with a 1:1 aspect resolution. I have not found an answer to that yet other than what nothke has said about Screen.SetResolution.