/// <summary>
    /// renders the gameobject path up to the root
    /// </summary>
    /// <param name="theComponent"></param>
    public static void RenderPath(Component theComponent)
    {
        GameObject aGameObject = theComponent.gameObject;

        // generate path for the gameObject
        string aPath = aGameObject.name;

        while (aGameObject.transform.parent != null)
        {
            aGameObject = aGameObject.transform.parent.gameObject;
            aPath       = string.Format("{0}/{1}", aGameObject.name, aPath);
        }

        KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
        {
            KGFGUIUtility.Label("path", KGFGUIUtility.eStyleLabel.eLabel, GUILayout.ExpandWidth(false));

            if (PrefabUtility.GetPrefabType(theComponent) == PrefabType.Prefab)
            {
                KGFGUIUtility.TextField(AssetDatabase.GetAssetPath(theComponent), KGFGUIUtility.eStyleTextField.eTextField, GUILayout.ExpandWidth(true));
            }
            else
            {
                KGFGUIUtility.TextField(aPath, KGFGUIUtility.eStyleTextField.eTextField, GUILayout.ExpandWidth(true));
            }
        }
        KGFGUIUtility.EndHorizontalBox();
    }
    /// <summary>
    /// Draw the full text search
    /// </summary>
    void DrawSearch()
    {
        GUI.SetNextControlName(itsControlSearchName);
        string aValue = KGFGUIUtility.TextField(itsSearch, KGFGUIUtility.eStyleTextField.eTextField);

        if (aValue != itsSearch)
        {
            itsSearch = aValue;
            UpdateItemFilter();
        }
    }
    void DrawFilterBox(KGFObjectListColumnItem theItem, uint theWidth)
    {
        if (theItem.GetReturnType().IsEnum || theItem.GetReturnType() == typeof(bool))
        {
            if (theItem.itsDropDown == null)
            {
                if (theItem.GetReturnType() == typeof(bool))
                {
                    theItem.itsDropDown = new KGFGUIDropDown((new List <string>(itsBoolValues)).InsertItem(NONE_STRING, 0), theWidth, 5, KGFGUIDropDown.eDropDirection.eUp);
                }
                else if (theItem.GetReturnType().IsEnum)
                {
                    theItem.itsDropDown = new KGFGUIDropDown(Enum.GetNames(theItem.GetReturnType()).InsertItem(NONE_STRING, 0), theWidth, 5, KGFGUIDropDown.eDropDirection.eUp);
                }

                theItem.itsDropDown.itsTitle = "";
                theItem.itsDropDown.SetSelectedItem(theItem.itsFilterString);
                theItem.itsDropDown.SelectedValueChanged += OnDropDownValueChanged;
            }
            theItem.itsDropDown.Render();
        }
        else if (theItem.GetReturnType() == typeof(string))
        {
            if (theItem.itsFilterString == null)
            {
                theItem.itsFilterString = "";
            }

            string aFilter = KGFGUIUtility.TextField(theItem.itsFilterString, KGFGUIUtility.eStyleTextField.eTextField, GUILayout.Width(theWidth));
            if (aFilter != theItem.itsFilterString)
            {
                theItem.itsFilterString = aFilter;
                UpdateList();
                OnSettingsChanged();
            }
        }
    }
    /// <summary>
    /// Render this control
    /// </summary>
    public void Render()
    {
        if (itsUpdateWish)
        {
            UpdateList();
        }

        int itsNumberOfPages = (int)Math.Ceiling((float)itsData.Rows.Count / (float)itsItemsPerPage);

        if (itsCurrentPage >= itsNumberOfPages)
        {
            itsCurrentPage = 0;
        }

        itsRepaintWish = false;
        itsGuiData.SetDisplayRowCount((uint)itsItemsPerPage);

        KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDecorated);
        {
            // categories view
            GUILayout.BeginVertical(GUILayout.Width(180));
            {
                itsListViewCategories.Render();
            }
            GUILayout.EndVertical();

            KGFGUIUtility.SpaceSmall();

            GUILayout.BeginVertical();
            {
                // item table
                itsGuiData.SetStartRow((uint)(itsCurrentPage * (uint)itsItemsPerPage));
                itsGuiData.Render();

                KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVerticalInteractive);
                {
                    // enum filter boxes
                    int aColumnNo = 0;
//						KGFGUIUtility.SpaceSmall();
                    foreach (KGFObjectListColumnItem anItem in itsListFieldCache)
                    {
                        aColumnNo++;

                        if (!anItem.itsDisplay)
                        {
                            continue;
                        }
                        if (!itsGuiData.GetColumnVisible(aColumnNo))
                        {
                            continue;
                        }

                        if (anItem.itsSearchable && (anItem.GetReturnType().IsEnum ||
                                                     anItem.GetReturnType() == typeof(bool) ||
                                                     anItem.GetReturnType() == typeof(string)))
                        {
                            GUILayout.BeginHorizontal(GUILayout.Width(itsGuiData.GetColumnWidth(aColumnNo)));
                            {
                                KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxInvisible);
                                DrawFilterBox(anItem, itsGuiData.GetColumnWidth(aColumnNo) - 4);
                                KGFGUIUtility.EndVerticalBox();
                            }
                            GUILayout.EndHorizontal();
                            KGFGUIUtility.Separator(KGFGUIUtility.eStyleSeparator.eSeparatorVerticalFitInBox);
                        }
                        else
                        {
                            GUILayout.BeginHorizontal(GUILayout.Width(itsGuiData.GetColumnWidth(aColumnNo)));
                            {
                                GUILayout.Label(" ");
                            }
                            GUILayout.EndHorizontal();
                            KGFGUIUtility.Separator(KGFGUIUtility.eStyleSeparator.eSeparatorVerticalFitInBox);
                            continue;
                        }
                    }
                    GUILayout.FlexibleSpace();
                }
                KGFGUIUtility.EndHorizontalBox();

                KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkMiddleVertical);
                {
                    GUILayout.Label("");
                    GUILayout.FlexibleSpace();
                }
                KGFGUIUtility.EndHorizontalBox();

                KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDarkBottom);
                {
                    GUILayout.BeginHorizontal();
                    {
                        if (!Application.isPlaying)
                        {
                            if (EventNew != null)
                            {
                                if (KGFGUIUtility.Button("New", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(75)))
                                {
                                    EventNew(this, null);
                                }
                            }
                            if (EventDelete != null)
                            {
                                if (KGFGUIUtility.Button("Delete", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(75)))
                                {
                                    EventDelete(this, null);
                                }
                            }

                            GUILayout.FlexibleSpace();
                        }

                        // full text search box
                        if (itsDisplayFullTextSearch)
                        {
                            GUI.SetNextControlName(itsControlSearchName);
                            string aNewString = KGFGUIUtility.TextField(itsFulltextSearch, KGFGUIUtility.eStyleTextField.eTextField, GUILayout.Width(200));
                            if (aNewString != itsFulltextSearch)
                            {
                                itsFulltextSearch = aNewString;
                                UpdateList();
                            }
                        }

                        KGFGUIUtility.Space();

                        bool anIncludeAll = KGFGUIUtility.Toggle(itsIncludeAll, "all Tags", KGFGUIUtility.eStyleToggl.eTogglSuperCompact, GUILayout.Width(70));
                        if (anIncludeAll != itsIncludeAll)
                        {
                            itsIncludeAll = anIncludeAll;
                            UpdateList();
                        }

                        if (KGFGUIUtility.Button("clear filters", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(100)))
                        {
                            itsFulltextSearch = "";
                            ClearFilters();
                            UpdateList();
                        }

                        GUILayout.FlexibleSpace();

                        KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxInvisible);
                        {
                            if (GetDisplayEntriesPerPage())
                            {
                                //number of items in List
                                if (KGFGUIUtility.Button("<", KGFGUIUtility.eStyleButton.eButtonLeft, GUILayout.Width(25)))
                                {
                                    switch (itsItemsPerPage)
                                    {
                                    case KGFeItemsPerPage.e25:
                                        itsItemsPerPage = KGFeItemsPerPage.e10;
                                        break;

                                    case KGFeItemsPerPage.e50:
                                        itsItemsPerPage = KGFeItemsPerPage.e25;
                                        break;

                                    case KGFeItemsPerPage.e100:
                                        itsItemsPerPage = KGFeItemsPerPage.e50;
                                        break;

                                    case KGFeItemsPerPage.e250:
                                        itsItemsPerPage = KGFeItemsPerPage.e100;
                                        break;

                                    case KGFeItemsPerPage.e500:
                                        itsItemsPerPage = KGFeItemsPerPage.e250;
                                        break;

                                    default:
                                        break;
                                    }
                                }

                                KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxMiddleHorizontal);
                                {
                                    string aLogsPerPageString = itsItemsPerPage.ToString().Substring(1) + " entries per page";
                                    KGFGUIUtility.Label(aLogsPerPageString, KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
                                }
                                KGFGUIUtility.EndVerticalBox();

                                if (KGFGUIUtility.Button(">", KGFGUIUtility.eStyleButton.eButtonRight, GUILayout.Width(25)))
                                {
                                    switch (itsItemsPerPage)
                                    {
                                    case KGFeItemsPerPage.e10:
                                        itsItemsPerPage = KGFeItemsPerPage.e25;
                                        break;

                                    case KGFeItemsPerPage.e25:
                                        itsItemsPerPage = KGFeItemsPerPage.e50;
                                        break;

                                    case KGFeItemsPerPage.e50:
                                        itsItemsPerPage = KGFeItemsPerPage.e100;
                                        break;

                                    case KGFeItemsPerPage.e100:
                                        itsItemsPerPage = KGFeItemsPerPage.e250;
                                        break;

                                    case KGFeItemsPerPage.e250:
                                        itsItemsPerPage = KGFeItemsPerPage.e500;
                                        break;

                                    default:
                                        break;
                                    }
                                }
                            }

                            GUILayout.Space(10.0f);

                            // page control
                            if (KGFGUIUtility.Button("<", KGFGUIUtility.eStyleButton.eButtonLeft, GUILayout.Width(25)) && itsCurrentPage > 0)
                            {
                                itsCurrentPage--;
                            }

                            KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxMiddleHorizontal);
                            {
                                string aString = string.Format("page {0}/{1}", itsCurrentPage + 1, Math.Max(itsNumberOfPages, 1));
                                KGFGUIUtility.Label(aString, KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
                            }
                            KGFGUIUtility.EndVerticalBox();

                            if (KGFGUIUtility.Button(">", KGFGUIUtility.eStyleButton.eButtonRight, GUILayout.Width(25)) && itsData.Rows.Count > ((itsCurrentPage + 1) * (int)itsItemsPerPage))
                            {
                                itsCurrentPage++;
                            }
                        }
                        KGFGUIUtility.EndHorizontalBox();
                    }
                    GUILayout.EndHorizontal();
                }
                KGFGUIUtility.EndVerticalBox();
            }
            GUILayout.EndVertical();
        }
        KGFGUIUtility.EndHorizontalBox();

        if (GUI.GetNameOfFocusedControl().Equals(itsControlSearchName))
        {
            if (itsFulltextSearch.Equals(itsTextSearch))
            {
                itsFulltextSearch = string.Empty;
            }
        }

        if (!GUI.GetNameOfFocusedControl().Equals(itsControlSearchName))
        {
            if (itsFulltextSearch.Equals(string.Empty))
            {
                itsFulltextSearch = itsTextSearch;
            }
        }
    }
示例#5
0
 /// <summary>
 /// renders a textfield left and a button right next to each other
 /// </summary>
 private void RenderControlCombination1()
 {
     KGFGUIUtility.TextField("textfield left", KGFGUIUtility.eStyleTextField.eTextFieldLeft);
     KGFGUIUtility.Button("button right", KGFGUIUtility.eStyleButton.eButtonRight);
 }