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.OnPreRender()

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

OnPreRender는 카메라가 씬(scene)의 렌더링을 시작하기 전에 호출됩니다.

스크립트가 카메라에 첨부되고 활성화 되어 있는 경우에만 호출됩니다.

카메라의 뷰 파라미터(즉 fieldOfView)를 변경하면, 다음 프레임에 효과가 적용됩니다. OnPreCull를 대신 사용할 수 있습니다. OnPreRender는 함수안에 간단히 yield 구문을 사용해서 co-routine으로 실행할 수 있습니다.

Also note that when OnPreRender is called, the camera's render target is not set up yet, and the depth texture(s) are not rendered yet either. If you want to do something later on (when the render target is already set), try using a CommandBuffer.

See Also: OnPostRender.

	// This script lets you enable/disable fog per camera.
	// by enabling or disabling the script in the title of the inspector
	// you can turn fog on or off per camera.

private var revertFogState = false; function OnPreRender () { revertFogState = RenderSettings.fog; RenderSettings.fog = enabled; } function OnPostRender () { RenderSettings.fog = revertFogState; }
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; } }