internal static GUIContent GetLocalizedTitleContentFromType(Type t)
        {
            EditorWindowTitleAttribute attr = GetEditorWindowTitleAttribute(t);

            if (attr != null)
            {
                string iconName = "";
                if (!string.IsNullOrEmpty(attr.icon))
                {
                    iconName = attr.icon;
                }
                else if (attr.useTypeNameAsIconName)
                {
                    iconName = t.ToString();
                }

                if (!string.IsNullOrEmpty(iconName))
                {
                    // This should error msg if icon is not found since icon has been explicitly requested by the user
                    return(EditorGUIUtility.TrTextContentWithIcon(attr.title, iconName));
                }

                return(EditorGUIUtility.TrTextContent(attr.title));
            }

            // Fallback to type name (Do not localize type name)
            return(new GUIContent(t.Name));
        }
Beispiel #2
0
        internal static GUIContent GetLocalizedTitleContentFromType(Type t)
        {
            EditorWindowTitleAttribute editorWindowTitleAttribute = EditorWindow.GetEditorWindowTitleAttribute(t);
            GUIContent result;

            if (editorWindowTitleAttribute != null)
            {
                string text = "";
                if (!string.IsNullOrEmpty(editorWindowTitleAttribute.icon))
                {
                    text = editorWindowTitleAttribute.icon;
                }
                else if (editorWindowTitleAttribute.useTypeNameAsIconName)
                {
                    text = t.ToString();
                }
                if (!string.IsNullOrEmpty(text))
                {
                    result = EditorGUIUtility.TextContentWithIcon(editorWindowTitleAttribute.title, text);
                }
                else
                {
                    result = EditorGUIUtility.TextContent(editorWindowTitleAttribute.title);
                }
            }
            else
            {
                result = new GUIContent(t.ToString());
            }
            return(result);
        }
Beispiel #3
0
        internal static GUIContent GetLocalizedTitleContentFromType(System.Type t)
        {
            EditorWindowTitleAttribute editorWindowTitleAttribute = GetEditorWindowTitleAttribute(t);

            if (editorWindowTitleAttribute != null)
            {
                string icon = "";
                if (!string.IsNullOrEmpty(editorWindowTitleAttribute.icon))
                {
                    icon = editorWindowTitleAttribute.icon;
                }
                else if (editorWindowTitleAttribute.useTypeNameAsIconName)
                {
                    icon = t.ToString();
                }
                if (!string.IsNullOrEmpty(icon))
                {
                    return(EditorGUIUtility.TextContentWithIcon(editorWindowTitleAttribute.title, icon));
                }
                return(EditorGUIUtility.TextContent(editorWindowTitleAttribute.title));
            }
            return(new GUIContent(t.ToString()));
        }