Version: 2020.2

Shader.SetGlobalTexture

切换到手册
public static void SetGlobalTexture (string name, Texture value);
public static void SetGlobalTexture (int nameID, Texture value);
public static void SetGlobalTexture (string name, RenderTexture value, Rendering.RenderTextureSubElement element);
public static void SetGlobalTexture (int nameID, RenderTexture value, Rendering.RenderTextureSubElement element);

参数

nameID 通过 Shader.PropertyToID 检索的属性的名称 ID。
name 属性的名称。
value 要设置的纹理。
element Optional parameter that specifies the type of data to set from the RenderTexture.

描述

为所有着色器设置全局纹理属性。

如果着色器需要全局属性,但材质未定义它们 (例如,如果着色器未在 Properties 代码块中公开它们), 则使用这些属性。

如果有一组全都使用相同“全局”纹理(例如,自定义漫射光照立方体贴图) 的自定义着色器,通常会使用该属性。 然后可以通过脚本设置该全局属性,不必在所有材质中设置 相同纹理。

By specifying a `RenderTextureSubElement`, you can indicate which type of data to set from the RenderTexture. The possible options are: RenderTextureSubElement.Color, RenderTextureSubElement.Depth, and RenderTextureSubElement.Stencil.

另请参阅:SetGlobalColorSetGlobalFloatMaterial class, ShaderLab 文档RenderTextureSubElement

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961