Version: 2022.3
public Texture GetTexture (string name);
public Texture GetTexture (int nameID);

参数

nameID 通过 Shader.PropertyToID 检索的属性的名称 ID。
name 属性的名称。

描述

获取指定的纹理。

许多着色器使用多个纹理。使用 GetTexture 可获取 propertyName 纹理。

If the texture is not found, the method writes an error message to the console and returns null.

Unity 内置着色器使用的常用纹理名称:\ "_MainTex" 是主漫射纹理。它还可以通过 mainTexture 属性进行访问。\ "_BumpMap" 是法线贴图。\ "_Cube" 是反射立方体贴图。

另请参阅:mainTexture 属性、SetTextureShader.PropertyToID