Custom Editor Textures for Asset Store

I’m currently working on a toolkit for the Asset Store, and have reached a point where I require textures to be used.

My problem is, although there are methods to gain access to textures at a particular file location, currently there doesn’t seem to be any way to always access a texture, regardless of where the user puts my toolkits folder.

Is there any way Unity has provided for such loading? Or am I going to have to work it through System code?

My solution in the end was to do a search for a uniquely named folder that all assets are in. Once this folder is found, it’s trivial to load in all the images.

string[] assetDir = Directory.GetDirectories(Application.dataPath, "FancyTextureFoundExample.*", SearchOption.AllDirectories);
string graphicFile = assetDir[0] + "/SubFolder/Graphic.png";
graphicFile = graphicFile .Substring(Application.dataPath.Length + 1);

icon = AssetDatabase.LoadAssetAtPath("Assets/" + graphicFile, typeof(Texture2D)) as Texture2D;

This solution works great as long as only one folder has been named that which your provide (in my example, a folder named FancyTextureFoundExample should only be found once). Hence why I do a search for one of the lower folders in the hierarchy, as it uses the name of the pack in it, a unique name which other developers (almost positively) won’t use.

Searching for something generic like “Graphics” or “Icons” or whatever is just going to end in disaster, there’s no way you can really assure that yours will be picked first.