Version: 5.3 (switch to 5.4b)
언어English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

MonoBehaviour.OnRenderObject()

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

닫기

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

닫기

취소

Switch to Manual

Description

OnRenderObject는 카메라가 씬(scene)을 렌더링 한 후에 호출됩니다.

Graphics.DrawMeshNow또는 다른 함수를 사용해서 사용자가 자신의 오브젝트를 렌더링 하는 경우에 사용할 수 있습니다. 이 기능은 OnPostRender와 비슷하지만, OnRenderObject는 이 함수를 포함한 스크립트를 가진 모든 오브젝트에서 호출됩니다: 카메라에 첨부되어 있는지 여부는 중요하지 않습니다.

    var mainMesh: Mesh;
	var miniMapMesh: Mesh;

function 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); } }
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Mesh mainMesh; public Mesh miniMapMesh; void OnRenderObject() { if (Camera.current.name == "MiniMapcam") Graphics.DrawMeshNow(miniMapMesh, transform.position, transform.rotation); else Graphics.DrawMeshNow(mainMesh, transform.position, transform.rotation); } }