Material材质 翻译:titan-志广
- color
- CopyPropertiesFromMaterial
- GetColor
- GetFloat
- GetMatrix
- GetTag
- GetTextureOffset
- GetTextureScale
- GetTexture
- GetVector
- HasProperty
- Lerp
- mainTextureOffset
- mainTextureScale
- mainTexture
- Material
- passCount
- renderQueue
- SetColor
- SetFloat
- SetMatrix
- SetPass
- SetTextureOffset
- SetTextureScale
- SetTexture
- SetVector
- shader
Material.mainTexture 主纹理
var mainTexture : Texture
Description描述
The main material's texture.
主材质的纹理
The same as using GetTexture or SetTexture with "_MainTex" name.
这个和带有 "_MainTex" 名称的 GetTexture 和 SetTexture 使用方法相同
参考:SetTexture, GetTexture.
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public Texture texture;
public void Awake() {
renderer.material.mainTexture = texture;
}
}
// Assign the texture exposed in the inspector the renderer's material
//将渲染材质的纹理暴露出来
var texture : Texture ;
renderer.material.mainTexture = texture;
// Change renderer's texture each changeInterval
// 改变渲染纹理各自的变化区间
// seconds from the texture array defined in the inspector.
//从检查器中定义的纹理阵列的秒数。
var textures : Texture [];
var changeInterval : float = 0.33;
function Update() {
if( textures.length == 0 ) // nothing if no textures //如果纹理是空的
return;
// we want this texture index now
//我们要得到纹理的索引
var index : int = Time.time / changeInterval;
// take a modulo with size so that animation repeats
//执行一个模运算随着值得大小做重复动画
index = index % textures.length;
// assign it
//指定材质
renderer.material.mainTexture = textures[index];
}
最后修改:2011年1月21日 Friday 22:18