The CompileShader
method in the Editor.EditorUtility
class is a static method used to compile a shader from a specified local path. It returns a task that, when completed, provides the results of the shader compilation process.
The CompileShader
method in the Editor.EditorUtility
class is a static method used to compile a shader from a specified local path. It returns a task that, when completed, provides the results of the shader compilation process.
To use the CompileShader
method, you need to provide the local path to the shader file, the shader compilation options, and a cancellation token. The method is asynchronous and returns a Task<ShaderCompile.Results>
, which you can await to get the results of the compilation.
// Example usage of CompileShader string shaderPath = "shaders/myShader.shader"; ShaderCompileOptions options = new ShaderCompileOptions(); CancellationToken cancellationToken = new CancellationToken(); Task<ShaderCompile.Results> compileTask = Editor.EditorUtility.CompileShader(shaderPath, options, cancellationToken); compileTask.ContinueWith(task => { if (task.IsCompletedSuccessfully) { ShaderCompile.Results results = task.Result; // Handle successful compilation } else { // Handle errors } });