path to texture problem -> EditorGUIUtility.FindTexture

Another newbie question! I can’t seem to load/use a texture for a gui button in my editor script?

I have an Editor folder in my project and under that folder is a script (EditorGUIUtilityFindTexture ) and a texture (Extents)
748-UnityTextures.png

I am using the script from the unity docs here

No matter what path I use it does not want to return the texture when calling EditorGUIUtility.FindTexture.

I am working on some editor tools and everything is going great until this texture problem. Below is some of my editor code …

public class QuickMouseEditingTools : Editor
{
    Texture2D blackTex;
    Texture2D whiteTex;
       Texture2D Extents;

    public void OnEnable()
    {
        if (this.blackTex == null)
        {
            this.blackTex = new Texture2D(1, 1, TextureFormat.RGBA32, false);
            this.blackTex.SetPixel(0, 0, new Color32(0, 0, 0, 255));
            this.blackTex.Apply();
        }

        if (this.whiteTex == null)
        {
            this.whiteTex = new Texture2D(1, 1, TextureFormat.RGBA32, false);
            this.whiteTex.SetPixel(0, 0, new Color32(255, 255, 255, 255));
            this.whiteTex.Apply();
        }
 
        this.Extents = EditorGUIUtility.FindTexture("Textures/Extents");
... etc

and I’m trying to setup a button in my editor using …

 if (GUILayout.Button(this.Extents, GUILayout.MinWidth(16), GUILayout.MinHeight(16)))
        { }

What would be the path to pass into EditorGUIUtility.FindTexture for it to return the Extents texture? (Extents texture type is set to Texture btw)

I’ve tried all sorts of crazy paths like Assets/Editor/Textures/Extents, Editor/Textures/Extents etc even trying to replace forward slashes with backslashes etc. Nothing seems to work.

Tried to do the same thing today and ran across your question.

As far as I can tell, the EditorGUIUtility.FindTexture function doesn’t actually do anything. Here’s a similar question and a workaround you can use.

Basically you can get a texture by using the EditorGUIUtility.Load function. The caveat is that this can only load stuff from a folder called “Editor Default Assets.” The official documentation explains it pretty well.