没有合适的资源?快使用搜索试试~ 我知道了~
Unity-C#-屏幕黑白渐变源码.txt
需积分: 49 5 下载量 13 浏览量
2019-08-04
16:46:33
上传
评论
收藏 4KB TXT 举报
温馨提示
试读
6页
通过shader来完成屏幕渐变的效果,可用于过场动画
资源推荐
资源详情
资源评论
Material ma;
float timer = 0;
void Start()
{
ma = new Material ( Shader .Find ( "Custom/Test3" ) ); //创建一个材质
}
void Update()
{
if (timer < 0 )
timer += Time.deltaTime * 0.5f;
else
timer = 0;
ma.SetFloat("_Float1", timer);
}
//默认方法,自动运行
void OnRenderImage ( RenderTexture source , RenderTexture destination )
{
//拷贝源纹理到目的渲染纹理。这主要是用于实现图像效果。
//Blit设置dest到激活的渲染纹理,在材质上设置source作为
//_MainTex属性,并且绘制一个全屏方块。
Graphics .Blit ( source , destination , ma );
}
float timer = 0;
void Start()
{
ma = new Material ( Shader .Find ( "Custom/Test3" ) ); //创建一个材质
}
void Update()
{
if (timer < 0 )
timer += Time.deltaTime * 0.5f;
else
timer = 0;
ma.SetFloat("_Float1", timer);
}
//默认方法,自动运行
void OnRenderImage ( RenderTexture source , RenderTexture destination )
{
//拷贝源纹理到目的渲染纹理。这主要是用于实现图像效果。
//Blit设置dest到激活的渲染纹理,在材质上设置source作为
//_MainTex属性,并且绘制一个全屏方块。
Graphics .Blit ( source , destination , ma );
}
//外部调用来控制渐变的开始
public void StartGradualChange()
{
timer = -1;
}
using UnityEngine;
using System.Collections;
public class ShaderTest : MonoBehaviour {
Material ma;
float timer = 0;
bool toHei = false ;
void Start ( )
{
ma = new Material ( Shader . Find ( "Custom/Test3" ) ); //创建一个材质
}
void Update ( )
{
if (Input .GetKeyDown(KeyCode.A))
剩余5页未读,继续阅读
资源评论
半天法师
- 粉丝: 60
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功