Calling EditorGUIUtility.Load will try the built-in editor resources by name. I have found some at the following locations via some scripts I found online “icons/d_unityeditor.gameview.png”, “icons/d_unityeditor.sceneview.png”, and “icons/d_movetool.png”
but I believe there are more of them. I’ve been unable to locate the folder where they are hiding at.
Does anyone happen to know where the list of those names are? Or could help me find the folder with all the editor resources?
I’m trying to make an editor tool and I’m specifically looking for the C# script image and the JS script image from Unity’s internals but I don’t know where to find them.
It may be possible to get what I’m looking for via AssetPreview.GetMiniTypeThumbnail which has helped me find other icons but it doesn’t like being fed typeof(MonoBehaviour); and I’m not sure what else to try…
Any help with helping me find these images would be great,
Thanks
If you still want the names, maybe you want to load the icons manually, I found this method in UnityEditorInternal.InternalEditorUtility, gives you all the icon names you need!
public static Texture2D GetIconForFile(string fileName)
{
int num = fileName.LastIndexOf('.');
string text = (num != -1) ? fileName.Substring(num + 1).ToLower() : string.Empty;
string text2 = text;
switch (text2)
{
case "boo":
return EditorGUIUtility.FindTexture("boo Script Icon");
case "cginc":
return EditorGUIUtility.FindTexture("CGProgram Icon");
case "cs":
return EditorGUIUtility.FindTexture("cs Script Icon");
case "guiskin":
return EditorGUIUtility.FindTexture("GUISkin Icon");
case "js":
return EditorGUIUtility.FindTexture("Js Script Icon");
case "mat":
return EditorGUIUtility.FindTexture("Material Icon");
case "prefab":
return EditorGUIUtility.FindTexture("PrefabNormal Icon");
case "shader":
return EditorGUIUtility.FindTexture("Shader Icon");
case "txt":
return EditorGUIUtility.FindTexture("TextAsset Icon");
case "unity":
return EditorGUIUtility.FindTexture("SceneAsset Icon");
case "asset":
case "prefs":
return EditorGUIUtility.FindTexture("GameManager Icon");
case "anim":
return EditorGUIUtility.FindTexture("Animation Icon");
case "meta":
return EditorGUIUtility.FindTexture("MetaFile Icon");
case "ttf":
case "otf":
case "fon":
case "fnt":
return EditorGUIUtility.FindTexture("Font Icon");
case "aac":
case "aif":
case "aiff":
case "au":
case "mid":
case "midi":
case "mp3":
case "mpa":
case "ra":
case "ram":
case "wma":
case "wav":
case "wave":
case "ogg":
return EditorGUIUtility.FindTexture("AudioClip Icon");
case "ai":
case "apng":
case "png":
case "bmp":
case "cdr":
case "dib":
case "eps":
case "exif":
case "gif":
case "ico":
case "icon":
case "j":
case "j2c":
case "j2k":
case "jas":
case "jiff":
case "jng":
case "jp2":
case "jpc":
case "jpe":
case "jpeg":
case "jpf":
case "jpg":
case "jpw":
case "jpx":
case "jtf":
case "mac":
case "omf":
case "qif":
case "qti":
case "qtif":
case "tex":
case "tfw":
case "tga":
case "tif":
case "tiff":
case "wmf":
case "psd":
case "exr":
return EditorGUIUtility.FindTexture("Texture Icon");
case "3df":
case "3dm":
case "3dmf":
case "3ds":
case "3dv":
case "3dx":
case "blend":
case "c4d":
case "lwo":
case "lws":
case "ma":
case "max":
case "mb":
case "mesh":
case "obj":
case "vrl":
case "wrl":
case "wrz":
case "fbx":
return EditorGUIUtility.FindTexture("Mesh Icon");
case "asf":
case "asx":
case "avi":
case "dat":
case "divx":
case "dvx":
case "mlv":
case "m2l":
case "m2t":
case "m2ts":
case "m2v":
case "m4e":
case "m4v":
case "mjp":
case "mov":
case "movie":
case "mp21":
case "mp4":
case "mpe":
case "mpeg":
case "mpg":
case "mpv2":
case "ogm":
case "qt":
case "rm":
case "rmvb":
case "wmw":
case "xvid":
return EditorGUIUtility.FindTexture("MovieTexture Icon");
case "colors":
case "gradients":
case "curves":
case "curvesnormalized":
case "particlecurves":
case "particlecurvessigned":
case "particledoublecurves":
case "particledoublecurvessigned":
return EditorGUIUtility.FindTexture("ScriptableObject Icon");
}
return EditorGUIUtility.FindTexture("DefaultAsset Icon");
}
EDIT:
Not icons, but also relevant - some GUI internal styles including the toolbarSearchField (the search field that’s used in the hierarchy and project views)
Copy/paste this code into a file called BuiltInResourcesWindow.cs, and put it in an Editor folder.
Then select Window / Built-in styles and icons.
This will show an editor window with all of the built in styles and icons. Once you find the one you want click on the button, this will copy the code for that style or icon.
Then go to your script editor and past the code.
In your case for the C# script Icon EditorGUIUtility.FindTexture( “cs Script Icon” ) this will return the C# script icon as a texture.
My answer is pretty much the same as @vexe , but at least it’s recent (tested with Unity 2018.2.20) and it fixes some icons that didn’t work (like .unity, .asset files and some others).
It adds some new extensions as well (.woff for fonts, .asset for ScriptableObjects).
With this code, you can get an icon in 3 ways :
GetIconByFileExtension(“.png”)
GetIconByName(“cs Script Icon”)
GetIconByType< Material>()
public static Texture2D GetIconByFileExtension(string fileExtension)
{
switch (fileExtension)
{
case “.boo”:
return GetIconByName(“boo Script Icon”);
case “.cginc”:
return GetIconByName(“CGProgram Icon”);
case “.cs”:
return EditorGUIUtility.FindTexture(“cs Script Icon”);
case “.guiskin”:
return GetIconByType();
case “.js”:
return GetIconByName(“Js Script Icon”);
case “.mat”:
return GetIconByType();
case “.prefab”:
return GetIconByName(“PrefabNormal Icon”);
case “.shader”:
return GetIconByType();
case “.txt”:
return GetIconByType();
case “.unity”:
return GetIconByType();
case “.prefs”:
return GetIconByName(“GameManager Icon”);
case “.anim”:
return GetIconByType();
case “.controller”:
return GetIconByType();
case “.meta”:
return GetIconByName(“MetaFile Icon”);
case “.ttf”:
case “.woff”:
case “.otf”:
case “.fon”:
case “.fnt”:
return GetIconByType();
case “.aac”:
case “.aif”:
case “.aiff”:
case “.au”:
case “.mid”:
case “.midi”:
case “.mp3”:
case “.mpa”:
case “.ra”:
case “.ram”:
case “.wma”:
case “.wav”:
case “.wave”:
case “.ogg”:
return GetIconByType();
case “.ai”:
case “.apng”:
case “.png”:
case “.bmp”:
case “.cdr”:
case “.dib”:
case “.eps”:
case “.exif”:
case “.gif”:
case “.ico”:
case “.icon”:
case “.j”:
case “.j2c”:
case “.j2k”:
case “.jas”:
case “.jiff”:
case “.jng”:
case “.jp2”:
case “.jpc”:
case “.jpe”:
case “.jpeg”:
case “.jpf”:
case “.jpg”:
case “.jpw”:
case “.jpx”:
case “.jtf”:
case “.mac”:
case “.omf”:
case “.qif”:
case “.qti”:
case “.qtif”:
case “.tex”:
case “.tfw”:
case “.tga”:
case “.tif”:
case “.tiff”:
case “.wmf”:
case “.psd”:
case “.exr”:
return GetIconByType();
case “.3df”:
case “.3dm”:
case “.3dmf”:
case “.3ds”:
case “.3dv”:
case “.3dx”:
case “.blend”:
case “.c4d”:
case “.lwo”:
case “.lws”:
case “.ma”:
case “.max”:
case “.mb”:
case “.mesh”:
case “.obj”:
case “.vrl”:
case “.wrl”:
case “.wrz”:
case “.fbx”:
return GetIconByType();
case “.asf”:
case “.asx”:
case “.avi”:
case “.dat”:
case “.divx”:
case “.dvx”:
case “.mlv”:
case “.m2l”:
case “.m2t”:
case “.m2ts”:
case “.m2v”:
case “.m4e”:
case “.m4v”:
case “.mjp”:
case “.mov”:
case “.movie”:
case “.mp21”:
case “.mp4”:
case “.mpe”:
case “.mpeg”:
case “.mpg”:
case “.mpv2”:
case “.ogm”:
case “.qt”:
case “.rm”:
case “.rmvb”:
case “.wmw”:
case “.xvid”:
return GetIconByType<UnityEngine.Video.VideoClip>();
case “.asset”:
case “.colors”:
case “.gradients”:
case “.curves”:
case “.curvesnormalized”:
case “.particlecurves”:
case “.particlecurvessigned”:
case “.particledoublecurves”:
case “.particledoublecurvessigned”://
return GetIconByName(“ScriptableObject Icon”);
}