Esempio n. 1
0
        private void IconGUI()
        {
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Folder Icon", EditorStyles.boldLabel);
            if (GUILayout.Button("None", EditorStyles.miniButton, GUILayout.ExpandWidth(true), GUILayout.Width(40)))
            {
                selectedIcon = null;
                folderIcon24 = folderOriginalIcon24 = null;
                folderIcon10 = folderOriginalIcon10 = null;
                return;
            }
            EditorGUILayout.EndHorizontal();

            ButtonGrid.ButtonAction bA = iconsUi.DrawGrid();
            if (bA != null || initIconsTexture)
            {
                IconGrid.IconElement icon = null;
                if (initIconsTexture)
                {
                    icon = selectedIcon;
                }
                else if (bA != null)
                {
                    icon = (IconGrid.IconElement)bA.ClickedElement;

                    if (!nameEdited)
                    {
                        styleName = bA.ClickedElement.GetElementName().Substring(0, Mathf.Min(bA.ClickedElement.GetElementName().Length, 14));
                    }
                }

                selectedIcon = icon;

                // High res icon
                folderIcon24 = new Texture2D(icon.HighResTex.width, icon.HighResTex.height, TextureFormat.RGBA32, true);
                Graphics.CopyTexture(icon.HighResTex, 0, 0, folderIcon24, 0, 0);
                folderOriginalIcon24 = icon.HighResTex;

                // Low res icon
                folderIcon10 = new Texture2D(icon.LowResTex.width, icon.LowResTex.height, TextureFormat.RGBA32, true);
                Graphics.CopyTexture(icon.LowResTex, 0, 0, folderIcon10, 0, 0);
                folderOriginalIcon10 = icon.LowResTex;

                initIconsTexture = false;
            }

            if (selectedIcon != null)
            {
                GUILayout.Space(4);
                styleProperties.iconOffset = DisplayOffsetField("Icon Offset", 100, styleProperties.iconOffset);
            }

            EditorGUILayout.EndVertical();
        }
Esempio n. 2
0
        public override void OnInspectorGUI()
        {
            // Not a folder or not openned with context menu
            if (!isFolder || !EditorPrefs.GetBool("ext_" + ResourceUtil.ExtensionName + "_enabled") || (!selectedByContext && !EditorPrefs.GetBool("ext_" + ResourceUtil.ExtensionName + "_simpleclick")))
            {
                base.OnInspectorGUI();
                return;
            }

            EditorGUI.EndDisabledGroup();             // Everything disabled fix

            // Is sub window activated ?
            if (nfsi != null)
            {
                nfsi.OnInspectorGUI(this);
                return;
            }

            // Custom style foldout

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Styles", EditorStyles.boldLabel);
            if (GUILayout.Button("New", EditorStyles.miniButton, GUILayout.ExpandWidth(true), GUILayout.Width(40)))
            {
                nfsi = new NewFolderStyleInspector();
                return;
            }
            EditorGUILayout.EndHorizontal();

            ButtonGrid.ButtonAction styleAction = customStyles.DrawGrid();
            if (styleAction != null)
            {
                if (styleAction.IsLeftClick)
                {
                    ApplyStyle((StyleGrid.StyleElement)styleAction.ClickedElement);
                }
                else
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Edit"), false, EditStyle, (StyleGrid.StyleElement)styleAction.ClickedElement);
                    menu.AddItem(new GUIContent("Delete"), false, AskDeleteStyle, (StyleGrid.StyleElement)styleAction.ClickedElement);
                    menu.ShowAsContext();
                }
            }

            EditorGUILayout.EndVertical();

            GUILayout.Space(10);

            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Reset", GUILayout.Width(80.0F), GUILayout.ExpandWidth(true)))
            {
                ApplyStyle(null);
            }



            EditorGUILayout.EndHorizontal();
        }
Esempio n. 3
0
        public void OnGUI()
        {
            ResourceUtil.Refresh();
            InitEditorStyles();

            // Is sub window activated ?
            if (nfsi != null)
            {
                currentScrollPos = EditorGUILayout.BeginScrollView(currentScrollPos);
                nfsi.OnInspectorGUI(this);

                EditorGUILayout.EndScrollView();
                return;
            }

            if (!TitleBarGUI())
            {
                return;
            }

            // Custom style foldout
            currentScrollPos = EditorGUILayout.BeginScrollView(currentScrollPos);

            EditorGUILayout.BeginHorizontal(toolBarStyle);
            EditorGUILayout.LabelField("Project styles:", toolBarLabelStyle);
            GUILayout.FlexibleSpace();

            if (GUILayout.Button(GUIHelper.ContentFromEditor("New", "Toolbar Plus"), toolBarButtonStyle))
            {
                nfsi = new NewFolderStyleInspector(null, false);
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.BeginVertical(styleListBackgroundStyle);
            GUILayout.Space(6);
            ButtonGrid.ButtonAction styleAction = customStyles.DrawGrid();
            if (styleAction != null)
            {
                if (styleAction.IsLeftClick)
                {
                    ApplyStyle((StyleGrid.StyleElement)styleAction.ClickedElement);
                }
                else
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Create variant"), false, CreateVariant, (StyleGrid.StyleElement)styleAction.ClickedElement);
                    menu.AddItem(new GUIContent("Edit"), false, EditStyle, (StyleGrid.StyleElement)styleAction.ClickedElement);
                    menu.AddItem(new GUIContent("Delete"), false, AskDeleteStyle, (StyleGrid.StyleElement)styleAction.ClickedElement);
                    menu.ShowAsContext();
                }
            }
            GUILayout.Space(2);
            GUILayout.EndVertical();

            EditorGUILayout.BeginHorizontal(toolBarStyle);
            GUILayout.FlexibleSpace();

            /*if (GUILayout.Button("Download Style packs", toolBarButtonStyle))
             * {
             *      //nfsi = new NewFolderStyleInspector();
             * }*/
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndScrollView();
        }
Esempio n. 4
0
        private void IconGUI()
        {
            EditorGUILayout.BeginHorizontal(FolderInspector.toolBarStyle);
            iconsOpen = EditorGUILayout.Foldout(iconsOpen, "Folder Icon", true);
            if (GUILayout.Button("Remove Icon", FolderInspector.toolBarButtonStyle, GUILayout.ExpandWidth(true), GUILayout.Width(80)))
            {
                selectedIcon = null;
                folderIcon48 = folderOriginalIcon48 = null;
                folderIcon24 = folderOriginalIcon24 = null;
                folderIcon10 = folderOriginalIcon10 = null;
                return;
            }
            EditorGUILayout.EndHorizontal();

            if (iconsOpen)
            {
                GUILayout.BeginVertical(FolderInspector.styleListBackgroundStyle);
                GUILayout.Space(6);
                ButtonGrid.ButtonAction bA = iconsUi.DrawGrid();
                if (bA != null || initIconsTexture)
                {
                    IconGrid.IconElement icon = null;
                    if (initIconsTexture)
                    {
                        icon = selectedIcon;
                    }
                    else if (bA != null)
                    {
                        icon = (IconGrid.IconElement)bA.ClickedElement;

                        if (!nameEdited)
                        {
                            styleName = bA.ClickedElement.GetElementName().Substring(0, Mathf.Min(bA.ClickedElement.GetElementName().Length, 14));
                        }
                    }

                    selectedIcon = icon;

                    // Very High res icon
                    folderIcon48 = new Texture2D(icon.VeryHighResTex.width, icon.VeryHighResTex.height, TextureFormat.RGBA32, true);
                    Graphics.CopyTexture(icon.VeryHighResTex, 0, 0, folderIcon48, 0, 0);
                    folderOriginalIcon48 = icon.VeryHighResTex;

                    // High res icon
                    folderIcon24 = new Texture2D(icon.HighResTex.width, icon.HighResTex.height, TextureFormat.RGBA32, true);
                    Graphics.CopyTexture(icon.HighResTex, 0, 0, folderIcon24, 0, 0);
                    folderOriginalIcon24 = icon.HighResTex;

                    // Low res icon
                    folderIcon10 = new Texture2D(icon.LowResTex.width, icon.LowResTex.height, TextureFormat.RGBA32, true);
                    Graphics.CopyTexture(icon.LowResTex, 0, 0, folderIcon10, 0, 0);
                    folderOriginalIcon10 = icon.LowResTex;

                    initIconsTexture = false;
                }

                EditorGUILayout.EndVertical();

                if (selectedIcon != null)
                {
                    GUILayout.BeginHorizontal(FolderInspector.toolBarStyle);
                    GUILayout.Label("Icon settings");
                    GUILayout.EndHorizontal();

                    GUILayout.Space(4);
                    styleProperties.iconOffset = DisplayOffsetField("Position", 100, styleProperties.iconOffset);
                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Middle", GUILayout.Width(70.0f)))
                    {
                        styleProperties.iconOffset = new Vector2Int(-11, -2);
                    }
                    if (GUILayout.Button("Left", GUILayout.Width(70.0f)))
                    {
                        styleProperties.iconOffset = new Vector2Int(-24, -2);
                    }
                    if (GUILayout.Button("Reset", GUILayout.Width(70.0f)))
                    {
                        styleProperties.iconOffset = Vector2Int.zero;
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.Space(6);
                }
            }
        }