Version: 2017.3

描述

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

另请参阅:OnPostRender

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; } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961