想要使相机目标屏幕画面停止渲染,官方给出了一条可实现的途径。
- Cameras cannot render to the Game Screen and a Render Texture at the same time, only one or the other.
- Setting this reference will disable this Camera’s capability to render to the screen.
意思是:像机不能在同一时间内同时渲染游戏屏幕和RenderTexture,只能渲染其中一个;为相机设置RenderTexture后将自动禁用该相机呈现到目标屏幕的能力。
所以想要达到相机停止画面渲染到目标屏幕,又想场地或其他相机照常运作,只需为需要的相机添加一个RenderTexture即可,这样该相机则会停止渲染自己的目标屏幕而是将画面渲染到RenderTexture中,而且这时该相机的目标屏幕还保留着之前最后的渲染画面。
【实现方法超简单】
//相机渲染画面到贴图,会自动暂停相机的目标屏幕渲染
camera.targetTexture = new RenderTexture(Screen.width, Screen.height, 0);
//恢复相机
camera.targetTexture = null;