Exemplo n.º 1
0
        /// <summary>
        /// IMGUI browser bar
        /// </summary>
        void BrowserBar()
        {
            float w2 = Screen.width / 2f - 5;

            GUI.Box(new Rect(0, 0, Screen.width, 20), GUIContent.none, EditorStyles.toolbar);

            GUI.enabled = history.Count > 0;
            if (GUI.Button(new Rect(5, 0, 20, 20), new GUIContent(EditorGUIUtility.isProSkin ? GetTexture("Back") : GetTexture("Back_Alt"), "Back"), EditorStyles.toolbarButton))
            {
                Back();
            }

            GUI.enabled = forwardHistory.Count > 0;
            if (GUI.Button(new Rect(25, 0, 20, 20), new GUIContent(EditorGUIUtility.isProSkin ? GetTexture("Forward") : GetTexture("Forward_Alt"), "Forward"), EditorStyles.toolbarButton))
            {
                Forward();
            }

            GUI.enabled = currentPageStateName != null && !currentPageStateName.Equals(pageRoot.GetType().FullName) || searchRoot.visible;
            if (GUI.Button(new Rect(48, 0, 20, 20), new GUIContent(EditorGUIUtility.isProSkin ? GetTexture("Home") : GetTexture("Home_Alt"), "Home"), EditorStyles.toolbarButton))
            {
                searchString       = string.Empty;
                searchRoot.visible = false;
                GUI.FocusControl(null);
                Home();
            }

            GUI.enabled = true;
            Rect searchRect = new Rect(w2, 2, w2, 16);

            using (EditorGUI.ChangeCheckScope changeCheckScope = new EditorGUI.ChangeCheckScope())
            {
                GUI.SetNextControlName(searchFieldName);
                searchString = EditorGUIExtensions.ToolbarSearchField(searchRect, searchString);

                if (!searchRoot.visible && !string.IsNullOrEmpty(searchString) && GUI.GetNameOfFocusedControl().Equals(searchFieldName))
                {
                    searchRoot.visible = true;
                    if (searchStringsCache.Count == 0)
                    {
                        DoSearch();
                    }
                }

                if (changeCheckScope.changed)
                {
                    DoSearch();
                }
            }
        }
Exemplo n.º 2
0
        private void LoadPage(IDocumentationPage <T> page, VisualElement rootOverride = null)
        {
            VisualElement root = rootOverride ?? contentRoot;

            SetCurrentDefaultRoot(root);
            root.Clear();

            //Constant header
            window.DrawConstantHeader();

            //Documentation
            page.DrawDocumentation(window);

            //Additions
            if (additions.TryGetValue(page, out var additionsList))
            {
                foreach (var addition in additionsList)
                {
                    addition.DrawDocumentation(window);
                }
            }

            page.DrawDocumentationAfterAdditions(window);

            //Button Links
            if (injectedButtonLinks.TryGetValue(page, out var buttonsBelow))
            {
                VisualElement injectedButtonContainer = new VisualElement();
                injectedButtonContainer.AddToClassList("injected-button-container");
                AddToRoot(injectedButtonContainer);
                SetCurrentDefaultRoot(injectedButtonContainer);

                foreach (DocumentationPage <T> .ButtonInjection button in buttonsBelow)
                {
                    DocumentationPage <T> pageOfOrigin = button.PageOfOrigin;
                    window.AddFullWidthButton(pageOfOrigin.Title, pageOfOrigin.Color, () => GoToPage(pageOfOrigin.GetType().FullName));
                }
            }

            currentPageStateName = page.GetType().FullName;
        }