public static Texture2D GetIcon(string filename, string filename2x = "", bool invertColors = false) { if (EditorGUIUtility.pixelsPerPoint > 1f && !string.IsNullOrEmpty(filename2x)) { filename = filename2x; } var key = invertColors ? "dark_" + filename : "light_" + filename; if (iconCache.ContainsKey(key)) { return(iconCache[key]); } Texture2D texture2D; using (var stream = AssemblyResources.ToStream(ResourceType.Icon, filename, EntryPoint.ApplicationManager.Environment)) { texture2D = stream.ToTexture2D(); } if (texture2D != null) { texture2D.hideFlags = HideFlags.HideAndDontSave; if (invertColors) { texture2D.InvertColors(); } iconCache.Add(key, texture2D); } return(texture2D); }