Rendering complete camera view(16:9) onto a texture in Unity3d

前端 未结 2 1137
囚心锁ツ
囚心锁ツ 2021-01-19 13:27

I was playing around with Unity\'s render textures where you can render a camera\'s view onto a texture. However, I noticed that it doesn\'t render the entire camera\'s view

2条回答
  •  無奈伤痛
    2021-01-19 14:04

    It's quite simple. No code required. You need to have same values between your RenderTexture size (x,y) and the RectTransform (width/height) you are using to render your texture to (the one with the RawImage component attached). Let's say you want a standard 16:9 HD aspect ratio. You need to set up your RenderTexture size to 1280x720 and your RectTransform Width and Height to 1280x720 as well. Then you can scale your RectTransform to any size you need to fit the UI layout you are designing.

提交回复
热议问题