Version: 2017.1


OnPreRender 在摄像机开始渲染场景前调用。


Note that if you change camera's viewing parameters (e.g. fieldOfView) here, they will only take effect the next frame. Do that in OnPreCull instead. OnPreRender can be a co-routine, simply use the yield statement in the function.

另请注意,当调用 OnPreRender 时,摄像机的渲染目标尚未设置,深度纹理 也尚未渲染。如果您想稍后(例如设置好渲染目标后)执行某些操作, 请尝试使用 CommandBuffer


using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { private bool revertFogState = false; void OnPreRender() { revertFogState = RenderSettings.fog; RenderSettings.fog = enabled; } void OnPostRender() { RenderSettings.fog = revertFogState; } }