Version: 2022.3
LanguageEnglish
  • C#

ShaderUtil

class in UnityEditor

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Utility functions to assist with working with shaders from the editor.

Static Properties

allowAsyncCompilationWhen true, asynchronous Shader compilation is allowed at the current call site.
anythingCompilingWhen true, the Editor is compiling some Shaders asynchronously at the point of query.
disableShaderOptimizationDisables shader optimization in the Editor.
hardwareSupportsRectRenderTextureDoes the current hardware support render textues.

Static Methods

ClearCachedDataClears all internally-cached data that was generated for the given shader, such as errors and compilation info.
ClearShaderMessagesClear compile time messages for the given shader.
CompilePassRequest the Editor to compile the Shader Variant needed for the specific pass of the given Material.
CreateComputeShaderAssetCreates a new ComputeShader object from the provided source code string. You can use this method alongside the ScriptedImporter to create custom compute shader generation tools in the Editor.
CreateShaderAssetCreates 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.
GetAllShaderInfoReturns an array of ShaderInfo of all available shaders. That includes built-in shaders.
GetCallableShaderCountReturns the number of callable Shaders defined whitin a given RayTracingShader.
GetCallableShaderNameReturns the name of a user-defined callable Shader from within a RayTracingShader.
GetCallableShaderParamSizeReturns the parameter size of a user-defined callable Shader from within a RayTracingShader.
GetComputeShaderMessageCountReturns the number of errors and warnings generated by the Unity Shader Compiler for the given ComputeShader.
GetComputeShaderMessagesReturns each error and warning generated by the Unity Shader Compiler for the given ComputeShader.
GetCurrentCustomEditorGets the current custom editor for the shader you pass in.Depending on the render pipeline asset assigned in your Graphics Settings, the custom editor can change if the shader has a different custom editor for one or multiple render pipeline assets.
GetCustomEditorForRenderPipelineGets the shader's custom editor class name for a specific render pipeline asset type.
GetMissShaderCountReturns the number of miss Shaders defined whitin a given RayTracingShader.
GetMissShaderNameReturns the name of a user-defined miss Shader from within a RayTracingShader.
GetMissShaderRayPayloadSizeReturns the ray payload size of a user-defined miss Shader from within a RayTracingShader.
GetPassKeywordsGets the local shader keywords that are valid for a Pass within a particular shader.
GetPropertyCountGet the number of properties in Shader s.
GetPropertyDescriptionGet the description of the shader propery at index propertyIdx of Shader s.
GetPropertyNameGet the name of the shader propery at index propertyIdx of Shader s.
GetPropertyTypeGet the ShaderProperyType of the shader propery at index propertyIdx of Shader s.
GetRangeLimitsGet Limits for a range property at index propertyIdx of Shader s.
GetRayGenerationShaderCountReturns the number of ray generation Shaders defined whitin a given RayTracingShader.
GetRayGenerationShaderNameReturns the name of a user-defined ray generation Shader from within a RayTracingShader.
GetRayTracingShaderMessageCountReturns the number of errors and warnings generated by the Shader Compiler for the given RayTracingShader.
GetRayTracingShaderMessagesReturns each error and warning generated by the Shader Compiler for the given RayTracingShader.
GetShaderDataGet the shader data for a specific shader.
GetShaderInfoGets ShaderInfo for the given shader.
GetShaderMessageCountReturns the number of errors and warnings generated by the Unity Shader Compiler for the given Shader.
GetShaderMessagesReturns each error and warning generated by the Unity Shader Compiler for the given Shader.
GetShaderPlatformKeywordsForBuildTargetGets the platform keywords for a shader, given a shader compiler platform, build target, and optional graphics tier. These platform keywords are necessary to properly compile a shader for a given target.
GetTexDimGets texture dimension of a shader property.
HasProceduralInstancingDetermines whether the specified Shader contains a valid Procedural Instancing variant.
IsPassCompiledChecks if the Shader variant for the given pass in the Material has already been compiled.
IsShaderPropertyHiddenReturns true if the shader propery at index propertyIdx is hidden with the [HideInInspector] attribute in the shader code.
IsShaderPropertyNonModifiableTexurePropertyIs the shader propery at index propertyIdx of Shader s a NonModifiableTextureProperty?
PassHasKeywordChecks whether a local shader keyword is valid for a Pass within a particular shader.
RegisterShaderRegister a user created shader.
RestoreAsyncCompilationRestores the previous Shader compilation mode in this CommandBuffer scope.
SetAsyncCompilationAdds shader compilation mode command in the CommandBuffer.
ShaderHasErrorChecks if a shader has any compilation errors. Ignores warnings.
ShaderHasWarningsChecks if a shader has any compilation warnings. Ignores errors.
UpdateShaderAssetReplaces the existing source code in the specified shader with the source code in the supplied string.