I’ve made a prototype of a space simulator, It’s based loosely on the idea of a “space shuttle simulator”. I’m going for the realistic approach, which means that I’m trying to shun exterior views.
I want to have screens in my cockpit, so the player can swivel their head and look at a virtual screen. I’ve been using “Normalized Viewport Rectangles” in my prototyping process; but that’s not a permanent solution. I am unsure if this is possible, and even more unsure of where to begin my research.
Any pointers in the right direction would be appreciated!
For this you need Unity pro since you need RenderTextures
It’s possible to workaround that limitation in the Free version, but it has horrible performance as you would use Texture2D.ReadPixels.
Well, you can get the effect of a RenderTexture with a script like this:
public class CustomRT : MonoBehaviour
public Rect rect;
public Material mat;
camera.pixelRect = rect;
texture = new Texture2D((int)rect.width,(int)rect.height,TextureFormat.ARGB32,false);
mat.mainTexture = texture;
Do the following steps:
- Attach the script to a second camera.
- Change the camera’s depth to be rendered before your main camera
- Create a material and assign it to the “mat” field
- Choose a rect size for the RT. Note: You can’t use a larger size than your screen has!
- Use the material on whatever geometry you like
The result looks like this:
ps: I’ve added a link at the bottom to a UnityPackage which contains the example scene.