Beispiel #1
0
        void DoGUI_()
        {
            var newWord = GUILayout.TextField(word);

            if (word != newWord)
            {
                word = newWord;
                UpdateList();
            }

            scrollView.DoGUI(prefsList, (prefs) => prefs.DoGUI());
        }
Beispiel #2
0
        public override void DoGUI()
        {
            using (new RGUI.IndentScope())
            {
                GUILayout.Label("IndentScope");
            }

            using (new RGUI.ColorScope(Color.green))
            {
                GUILayout.Label("ColorScope");
            }

            using (new RGUI.BackgroundColorScope(Color.red))
            {
                GUILayout.Button("BackgroundColorScope");
            }

            using (new RGUI.EnabledScope(false))
            {
                GUILayout.Label("EnabledScope");
            }

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("Popup");

                GUILayout.Box("Popup");
                var resultIdx = RGUI.PopupOnLastRect(new[] { "Button One", "Button Two", "Button Three" });
                if (resultIdx >= 0)
                {
                    Debug.Log($"Popup: Button{resultIdx + 1}");
                }
            }

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("Popup with so many elements");

                GUILayout.Box("A scrollbar appears when the pop-up protrudes from the screen");
                RGUI.PopupOnLastRect(Enumerable.Range(0, 100).Select(i => "Element " + i.ToString()).ToArray());
            }

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("SelectionPopup");
                selectionPopupIdx = RGUI.SelectionPopup(selectionPopupIdx, new[] { "One", "Two", "Three" });
            }

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("SelectionPopupStr");
                selectionPopupStr = RGUI.SelectionPopup(selectionPopupStr, new[] { "One", "Two", "Three" });
            }



            GUILayout.Space(8f);


            GUILayout.Label("FastScrollView (doesn't slow down even if there are many items.)");
            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("ItemNum");
                if (int.TryParse(GUILayout.TextField(scrollViewItemCount.ToString()), out var count))
                {
                    if (scrollViewItemCount != count)
                    {
                        scrollViewItemCount = count;
                        fastScrollView.SetNeedUpdateLayout();
                    }
                }
            }

            using (new RGUI.IndentScope())
            {
                useFastScrollView = GUILayout.Toggle(useFastScrollView, nameof(useFastScrollView));
                var items = Enumerable.Range(0, scrollViewItemCount);

                using (new GUILayout.VerticalScope(GUILayout.Height(500)))
                {
                    if (useFastScrollView)
                    {
                        fastScrollView.DoGUI(items, (item) => GUILayout.Label($"FastScrollView item: {item}"));
                    }
                    else
                    {
                        using (var sv = new GUILayout.ScrollViewScope(scPos))
                        {
                            scPos = sv.scrollPosition;
                            items.ToList().ForEach(i => GUILayout.Label($"ScrollView item: {i}"));
                        }
                    }
                }
            }
        }
Beispiel #3
0
        protected override void OnGUIInternal()
        {
            using (new GUILayout.HorizontalScope())
            {
                if (GUILayout.Button("Save"))
                {
                    Prefs.Save();
                }
                if (GUILayout.Button("Load"))
                {
                    Prefs.Load();
                }
                if (GUILayout.Button("DeleteAll"))
                {
                    if (EditorUtility.DisplayDialog("DeleteAll", "Are you sure to delete all current prefs parameters?",
                                                    "DeleteAll", "Don't Delete"))
                    {
                        Prefs.DeleteAll();
                    }
                }
            }

            var prefsAll = ObjectPrefsUtility.objPrefsList.SelectMany(gp => gp.prefsList).ToList();
            var currentToDefaultEnable = !Application.isPlaying && prefsAll.Any(prefs => !prefs.IsDefault);

            using (new RGUI.EnabledScope(currentToDefaultEnable))
            {
                if (GUILayout.Button("Open Current To Default Window"))
                {
                    if (setCurrentToDefaultWindow == null)
                    {
                        setCurrentToDefaultWindow = CreateInstance <SetCurrentToDefaultWindow>();
                    }
                    setCurrentToDefaultWindow.parentWindow = this;
                    setCurrentToDefaultWindow.ShowUtility();
                }
            }

            GUILayout.Space(8f);

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("Order");

                order = (Order)GUILayout.Toolbar((int)order, System.Enum.GetNames(typeof(Order)));
                EditorGUILayout.Space();
            }

            GUILayout.Space(8f);

            extension?.GUIHeadLine();

            switch (order)
            {
            case Order.AtoZ:
                scrollViewAtoZ.DoGUI(prefsAll.OrderBy(p => p.key), (prefs) =>
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        extension?.GUIPrefsLeft(prefs);
                        prefs.DoGUI();
                    }
                });
                break;

            case Order.GameObject:
                scrollViewGameObject.DoGUI(ObjectPrefsUtility.objPrefsList, (gp) =>
                {
                    LabelWithEditPrefix(gp);

                    using (new RGUI.IndentScope())
                    {
                        gp.prefsList.ToList().ForEach(prefs =>
                        {
                            using (new GUILayout.HorizontalScope())
                            {
                                extension?.GUIPrefsLeft(prefs);
                                prefs.DoGUI();
                            }
                        });
                    }
                });
                break;
            }
        }