public void SetTexture (string name, Texture value);
public void SetTexture (int nameID, Texture value);

Parameters

nameID 属性名称 ID,使用 Shader.PropertyToID 获取。
name 属性名称,例如“_MainTex”。
value 要设置的纹理。

Description

设置指定的纹理。

许多着色器使用多个纹理。使用 SetTexture 可更改纹理(由着色器属性名称或唯一的属性名称 ID 标识)。

When setting textures on materials using the Standard Shader, you should be aware that you may need to use EnableKeyword to enable features of the shader that were not previously in use. For more detail, read Accessing Materials via Script.

Common texture names used by Unity's builtin shaders:
"_MainTex" is the main diffuse texture. This can also be accessed via mainTexture property.
"_BumpMap" is the normal map.

另请参阅:mainTexture 属性、GetTextureShader.PropertyToIDProperties in Shader Programs