示例#1
0
        private static void OnMenuItemClicked()
        {
            selectedByContext = true;
            nfsi = null;

            TryOpenSelection();

            if (currentWindow != null)
            {
                currentWindow.Repaint();
            }
        }
示例#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();
        }
示例#3
0
 public void CloseSubWindow()
 {
     nfsi = null;
     GUI.FocusControl(null);
     customStyles.Init();
 }
示例#4
0
 public void EditStyle(object style)
 {
     nfsi = new NewFolderStyleInspector((StyleGrid.StyleElement)style);
 }
示例#5
0
 public void CreateVariant(object style)
 {
     nfsi = new NewFolderStyleInspector((StyleGrid.StyleElement)style, true);
 }
示例#6
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();
        }