Shader.Find returns null

Hi,

I can’t find any Shader using Shader.Find.

Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class testgraph : MonoBehaviour
{
Shader shader1;
Shader shader2;

void Start()
{
shader1 = Shader.Find(“Unlit graph”);
shader2 = Shader.Find(“outlineGraph”);
Debug.Log(shader1);
Debug.Log(shader2);
}
}

Both debugs return null. I’ve already set both shaders to “all include” in the settings, and both are located inside the Resources folder. Also, both are already used in scene.

Any idea why it returns null?

Thanks!

I recommend not using Shader.Find at all. It’s unreliable, specially when using asset bundles, and referencing things via strings is bad in general.

Instead, add a Shader field to your Monobehaviour and assign the shader directly to it in the editor. This is less error prone and will cause Unity to know you are using that shader, no matter where it is.

Thanks. I’m stupid. you’re awesome. It’s working.