Material.SetTexture 设置纹理

function SetTexture (propertyName : string, texture : Texture) : void

Description描述

Set a named texture.

设置已命名纹理

Many shaders use more than one texture. Use SetTexture to change the propertyName texture.

许多着色器都使用超过一张纹理,可以使用SetTexture改变 propertyName的纹理

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

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

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

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

参见: mainTexture 属性, GetTexture .

using UnityEngine;

using System.Collections;



public class example : MonoBehaviour {

	public Texture bumpMap;

	public void Awake() {

		renderer.material.SetTexture("_BumpMap", bumpMap);

	}

}
var bumpMap : Texture;

renderer.material.SetTexture("_BumpMap", bumpMap);
Page last updated: 2011-1-22