Shader.Find() equivalent for Compute Shaders?

I’d like to reference a Compute Shader from within a script without having to assign it to a public variable using the editor. This can be done with normal shaders using Shader.Find(). Is there an equivalent for Compute Shaders?

1 Like

Turns out you can load it like any other asset. Put the compute shader in a “Resources” folder, and then load it during runtime with:

ComputeShader cs = (ComputeShader)Resources.Load("NameOfShader")

Do not include the file’s extension (i.e *.compute).

ComputeShader cs;
string shaderName = “name_of_shader”;
ComputeShader compShaders = (ComputeShader)Resources.FindObjectsOfTypeAll(typeof(ComputeShader));
for (int i = 0; i < compShaders.Length; i++)
{
if (compShaders*.name == shaderName)*

  • {*
    _ cs = compShaders*;_
    _
    break;_
    _
    }_
    _
    }*_