UpdateShaderAsset
Replaces the source code of a shader during an asset import, and registers its dependencies with the asset system.
阅读时间2 分钟最后更新于 16 天前
Definition
- Type: Method
- Namespace: UnityEditor
- Assembly: UnityEditor.CoreModule
UpdateShaderAsset(AssetImportContext, Shader, string, bool)
Replaces the source code of a shader during an asset import, and registers its dependencies with the asset system.
public static void UpdateShaderAsset(AssetImportContext context, Shader shader, string source, bool compileInitialShaderVariants)
Parameters
The import context that registers the shader dependencies with the asset system. Pass the context from a ScriptedImporter when you call this method during an import.
Set to true to compile the initial shader variants from the source code. Set to false to skip compiling them.
Remarks
Use this overload in a ScriptedImporter to update a shader that custom shader generation tools created. The import context lets the asset system track the files that the shader depends on, so Unity reimports the shader when they change.
UpdateShaderAsset(Shader, string)
Replaces the source code of a shader and compiles its initial shader variants.
public static void UpdateShaderAsset(Shader shader, string source)
Parameters
Remarks
Use this overload only to update a transient shader that isn't serialized or stored anywhere. Unity compiles the initial shader variants and doesn't register any shader dependencies with the asset system. To update a persistent shader, always use the overload that takes an AssetImportContext. To control compilation, use the overload that takes .
compileInitialShaderVariantsUpdateShaderAsset(Shader, string, bool)
Replaces the source code of a shader, with the option to skip compiling the initial shader variants.
public static void UpdateShaderAsset(Shader shader, string source, bool compileInitialShaderVariants)
Parameters
Remarks
Use this overload only to update a transient shader that isn't serialized or stored anywhere. Unity doesn't register any shader dependencies with the asset system. To update a persistent shader, always use the overload that takes an AssetImportContext.