MonoBehaviour.OnPostRender 当渲染之后

function OnPostRender () : void

Description描述

OnPostRender is called after a camera finished rendering the scene.

在相机完成场景渲染之后被调用。

This function is called only if the script is attached to the camera and is enabled. OnPostRender can be a co-routine, simply use the yield statement in the function.

只有该脚本附于相机并启用时才会调用这个函数。OnPostRender可以是一个协同程序,在函数中调用yield语句即。

OnPostRender is called after the camera renders all its objects. If you want to do something after all cameras and GUI is rendered, use WaitForEndOfFrame coroutine.

OnPostRender在相机渲染完所有物体之后被调用。如果你想在相机和GUI渲染完成后做些什么,就用WaitForEndOfFrame协同程序。

参见:OnPreRender WaitForEndOfFrame

// When attached to a camera, will clear alpha channel
// of camera's render texture to pure white.
// Useful if you have camera rendering into a texture and later
// want to display it in GUI.
// 当附于一个相机后,将清理alpha管道为纯白色.如果你想渲染到纹理并显示在GUI上可以使用它.
private var mat : Material;

function OnPostRender() {
	// Create a shader that renders white only to alpha channel
	// 创建一个着色器,将alpha通道渲染为白色
	if(!mat) {
		mat = new Material( "Shader \"Hidden/SetAlpha\" {" +
		"SubShader {" +
		" Pass {" +
		" ZTest Always Cull Off ZWrite Off" +
		" ColorMask A" +
		" Color (1,1,1,1)" +
		" }" +
		"}" +
		"}"
		);
	}
	// Draw a quad over the whole screen with the above shader
	// 用上面的着色器绘制一个四边形覆盖整个屏幕
	GL.PushMatrix ();
	GL.LoadOrtho ();
	for (var i = 0; i < mat.passCount; ++i) {
		mat.SetPass (i);
		GL.Begin( GL.QUADS );
		GL.Vertex3( 0, 0, 0.1 );
		GL.Vertex3( 1, 0, 0.1 );
		GL.Vertex3( 1, 1, 0.1 );
		GL.Vertex3( 0, 1, 0.1 );
		GL.End();
	}
	GL.PopMatrix ();
}


代码无效果,望大神解答
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值