Version: 2022.1

ShaderUtil.CreateShaderAsset

切换到手册
public static Shader CreateShaderAsset (AssetImporters.AssetImportContext context, string source, bool compileInitialShaderVariants);
public static Shader CreateShaderAsset (string source, bool compileInitialShaderVariants);
public static Shader CreateShaderAsset (string source);

参数

context A context object that the asset system needs to register shader dependencies properly.
source 一个字符串,包含在 ShaderLab 代码中编写的着色器。
compileInitialShaderVariants 设置为 true 可编译包含在源字符串中的 ShaderLab 代码;否则为 false。

描述

Creates a new Shader object from the provided source code string. You can use this method alongside the ScriptedImporter to create custom shader generation tools in the Editor.