Version: 2020.3

Camera.OnRenderObject()

切换到手册

描述

在摄像机渲染场景后,将调用 OnRenderObject。

您可以将该函数与 Graphics.DrawMeshNow 或其他函数配合使用,从而渲染您自己的对象。 该函数与 OnPostRender 类似,但 OnRenderObject 是在具有包含该函数的脚本 (无论是否附加到摄像机)的任何对象上调用的。

using UnityEngine;

public class Example : MonoBehaviour { Mesh mainMesh; Mesh miniMapMesh;

void OnRenderObject() { // Render different meshes for the object depending on whether // the main camera or minimap camera is viewing. if (Camera.current.name == "MiniMapcam") { Graphics.DrawMeshNow(miniMapMesh, transform.position, transform.rotation); } else { Graphics.DrawMeshNow(mainMesh, transform.position, transform.rotation); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961