Material.SetTextureOffset 设置纹理偏移

今天在做像素鸟的时候,小鸟飞行的动画是一个3帧的图片,在跟着视频做的时候里面有个

this.GetComponent<Renderer>().material.SetTextureOffset("_MainTex",new Vector2(0.33333f * frameIndex,0));

这行代码就是控制显示某一帧的。里面有个参数“_MainTex”,让我很是不明白。下面是我查阅的圣典中的资料:

function SetTextureOffset (propertyName : string, offset : Vector2) : void

Description描述

Sets the placement offset of texture propertyName.

设置纹理propertyName的偏移量。

Common texture names used by Unity's builtin shaders:
在unity着色器中使用的统一的纹理名称

"_MainTex" is the main diffuse texture .This can also be accessed via  mainTextureOffset property.
"_MainTex"是主要的漫反射纹理,也能通过  mainTextureOffset 属性访问

"_BumpMap" is the normal map.
"_BumpMap"是法线贴图

"_Cube" is the reflection cubemap.
"_Cube"是反射cubemap.(立方体贴图)

参见:  mainTextureOffset 属性,  GetTextureOffset .

// Scroll main texture based on time
//根据时间滚动主纹理

var scrollSpeed : float = 0.5;

function Update () {
	var offset : float = Time.time * scrollSpeed;
	renderer.material.SetTextureOffset ("_MainTex", Vector2 (offset,0));
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yy763496668

您的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值