Esempio n. 1
0
        private static EditorTexture GetBuiltInUnityTypeIcon(Type type)
        {
            Texture2D icon = null;

            try
            {
                if (typeof(EditorWindow).IsAssignableFrom(type))
                {
                    try
                    {
                        icon = ((GUIContent)UnityEditorDynamic.EditorWindow.GetLocalizedTitleContentFromType(type))?.image as Texture2D;
                    }
                    catch
                    {
                        icon = null;
                    }
                }

                if (icon == null)
                {
                    icon = UnityEditorDynamic.EditorGUIUtility.FindTexture(type);
                }

                if (icon == null)
                {
                    icon = (Texture2D)EditorGUIUtility.ObjectContent(null, type).image;
                }
            }
            catch (Exception) {}

            if (icon != null)
            {
                return(EditorTexture.Single(icon));
            }

            return(null);
        }
            public void Load()
            {
                storage.Bind(nameof(empty), () => EditorTexture.Single(ColorPalette.transparent.GetPixel()));

                // Messages
                storage.Bind(nameof(informationMessage), () => LudiqGUIUtility.LoadBuiltinTexture("console.infoicon"));
                storage.Bind(nameof(questionMessage), () => resources.LoadIcon("Icons/Messages/Question.png"));
                storage.Bind(nameof(warningMessage), () => LudiqGUIUtility.LoadBuiltinTexture("console.warnicon"));
                storage.Bind(nameof(successMessage), () => resources.LoadIcon("Icons/Messages/Success.png"));
                storage.Bind(nameof(errorMessage), () => LudiqGUIUtility.LoadBuiltinTexture("console.erroricon"));

                // States
                storage.Bind(nameof(warningState), () => LudiqGUIUtility.LoadBuiltinTexture("console.warnicon"));
                storage.Bind(nameof(successState), () => resources.LoadIcon("Icons/State/Success.png"));
                storage.Bind(nameof(errorState), () => LudiqGUIUtility.LoadBuiltinTexture("console.erroricon"));
                storage.Bind(nameof(progress), () => resources.LoadIcon("Icons/State/Progress.png"));

                // Versioning
                storage.Bind(nameof(upgrade), () => resources.LoadIcon("Icons/Versioning/Upgrade.png"));
                storage.Bind(nameof(upToDate), () => resources.LoadIcon("Icons/Versioning/UpToDate.png"));
                storage.Bind(nameof(downgrade), () => resources.LoadIcon("Icons/Versioning/Downgrade.png"));

                // Windows
                storage.Bind(nameof(supportWindow), () => resources.LoadIcon("Icons/Windows/SupportWindow.png"));
                storage.Bind(nameof(sidebarAnchorLeft), () => resources.LoadTexture("Icons/Windows/SidebarAnchorLeft.png", CreateTextureOptions.PixelPerfect));
                storage.Bind(nameof(sidebarAnchorRight), () => resources.LoadTexture("Icons/Windows/SidebarAnchorRight.png", CreateTextureOptions.PixelPerfect));

                // Configuration
                storage.Bind(nameof(editorPref), () => resources.LoadTexture("Icons/Configuration/EditorPref.png", new TextureResolution[] { 12, 24 }, CreateTextureOptions.PixelPerfect));
                storage.Bind(nameof(projectSetting), () => resources.LoadTexture("Icons/Configuration/ProjectSetting.png", new TextureResolution[] { 12, 24 }, CreateTextureOptions.PixelPerfect));

                // Other
                storage.Bind(nameof(@null), () => resources.LoadIcon("Icons/Null.png"));
                storage.Bind(nameof(generic), () => resources.LoadIcon("Icons/Generic.png"));
                storage.Bind(nameof(@new), () => resources.LoadIcon("Icons/New.png"));
                storage.Bind(nameof(folder), () => EditorTexture.Single(AssetDatabase.GetCachedIcon("Assets")));
            }
Esempio n. 3
0
        private static EditorTexture GetScriptTypeIcon(string scriptName)
        {
            var scriptObject = (UnityObject)EditorGUIUtility_GetScriptObjectFromClass.Invoke(null, new object[] { scriptName });

            if (scriptObject != null)
            {
                var scriptIcon = (Texture2D)EditorGUIUtility_GetIconForObject.Invoke(null, new object[] { scriptObject });

                if (scriptIcon != null)
                {
                    return(EditorTexture.Single(scriptIcon));
                }
            }

            var scriptPath = AssetDatabase.GetAssetPath(scriptObject);

            if (scriptPath != null)
            {
                switch (Path.GetExtension(scriptPath))
                {
                case ".js":

                    return(EditorTexture.Single((Texture2D)EditorGUIUtility.IconContent("js Script Icon").image));

                case ".cs":

                    return(EditorTexture.Single((Texture2D)EditorGUIUtility.IconContent("cs Script Icon").image));

                case ".boo":

                    return(EditorTexture.Single((Texture2D)EditorGUIUtility.IconContent("boo Script Icon").image));
                }
            }

            return(null);
        }
Esempio n. 4
0
        public static EditorTexture Icon(this UnityObject obj)
        {
            foreach (var handler in unityObjectIconHandlers)
            {
                if (handler(obj, out var handlerIcon))
                {
                    return(handlerIcon);
                }
            }

            var icon = AssetPreview.GetMiniThumbnail(obj);

            if (icon == null)
            {
                icon = (Texture2D)EditorGUIUtility.ObjectContent(obj, obj?.GetType()).image;
            }

            if (icon != null)
            {
                return(EditorTexture.Single(icon));
            }

            return(null);
        }
Esempio n. 5
0
 public Root(GUIContent header) : base(FuzzyOptionMode.Branch)
 {
     label = header?.text ?? "Fuzzy";
     icon  = EditorTexture.Single(header?.image);
 }