今天在做像素鸟的时候,小鸟飞行的动画是一个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 .
Material.SetTextureOffset 设置纹理偏移
于 2016-02-18 09:02:22 首次发布