Exemplo n.º 1
0
        protected override void OnGUIInternal()
        {
            _prefsEnum.OnGUI();
            _prefsString.OnGUI();
            _prefsInt.OnGUI();
            _prefsFloat.OnGUI();
            _prefsFloat.OnGUISlider();
            _prefsBool.OnGUI();
            _prefsVector2.OnGUI();
            _prefsVector2.OnGUISlider();
            _prefsVector3.OnGUI();
            _prefsVector3.OnGUISlider();
            _prefsVector4.OnGUI();
            _prefsVector4.OnGUISlider();
            _prefsVector2Int.OnGUI();
            _prefsVector2Int.OnGUISlider();
            _prefsVector3Int.OnGUI();
            _prefsVector3Int.OnGUISlider();
            _prefsRect.OnGUI();
            _prefsRect.OnGUISlider();
            _prefsColor.OnGUI();


            _prefsIPEndPoint.OnGUI();

            // return true if value was changed
            if (_prefsColor.OnGUISlider())
            {
                // use as native type
                Color color = _prefsColor;
                Debug.Log("Changed. " + color);
            }


            // PrefsList can call runtime element GUI
            _prefsList.OnGUI((element) =>
            {
                element.name     = GUIUtil.Field(element.name ?? "", "name");
                element.intValue = GUIUtil.IntButton(element.intValue, "intValue");
            },
                             "PrefsList runtime element GUI");


            _prefsList.OnGUI("PrefsList automaticaly call element.DebugMenu() if it is IDebugMenu");



            GUILayout.Label($"file path: {PrefsGUI.Wrapper.PrefsWrapperPathSelector.path}");

            if (GUILayout.Button("Save"))
            {
                Prefs.Save();
            }
            if (GUILayout.Button("DeleteAll"))
            {
                Prefs.DeleteAll();
            }
        }
Exemplo n.º 2
0
        protected override void OnGUIInternal()
        {
            using (var h0 = 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 currentToDefaultEnable = !Application.isPlaying && PrefsList.Any(prefs => !prefs.IsDefault);

            GUI.enabled = currentToDefaultEnable;
            if (GUILayout.Button("Open Current To Default Window"))
            {
                if (setCurrentToDefaultWindow == null)
                {
                    setCurrentToDefaultWindow = CreateInstance <SetCurrentToDefaultWindow>();
                }
                setCurrentToDefaultWindow.parentWindow = this;
                setCurrentToDefaultWindow.ShowUtility();
            }
            GUI.enabled = true;

            GUILayout.Space(8f);

            using (var sc = new GUILayout.ScrollViewScope(scrollPosition))
            {
                scrollPosition = sc.scrollPosition;

                var sync = FindObjectOfType <PrefsGUISync>();
                if (sync != null)
                {
                    GUILayout.Label("sync");
                }

                PrefsList.ToList().ForEach(prefs =>
                {
                    using (var h = new GUILayout.HorizontalScope())
                    {
                        if (sync != null)
                        {
                            var key    = prefs.key;
                            var isSync = !sync._ignoreKeys.Contains(key);

                            if (isSync != GUILayout.Toggle(isSync, "", GUILayout.Width(16f)))
                            {
                                Undo.RecordObject(sync, "Change PrefsGUI sync flag");

                                if (isSync)
                                {
                                    sync._ignoreKeys.Add(key);
                                }
                                else
                                {
                                    sync._ignoreKeys.Remove(key);
                                }
                            }
                        }

                        prefs.OnGUI();
                    }
                });
            }

            if ((setCurrentToDefaultWindow != null) && Event.current.type == EventType.repaint)
            {
                setCurrentToDefaultWindow.Repaint();
            }
        }
        protected override void OnGUIInternal()
        {
            _prefsEnum.OnGUI();
            _prefsString.OnGUI();
            _prefsInt.OnGUI();
            _prefsFloat.OnGUI();
            _prefsFloat.OnGUISlider();
            _prefsBool.OnGUI();
            _prefsVector2.OnGUI();
            _prefsVector2.OnGUISlider();
            _prefsVector3.OnGUI();
            _prefsVector3.OnGUISlider();
            _prefsVector4.OnGUI();
            _prefsVector4.OnGUISlider();
            _prefsVector2Int.OnGUI();
            _prefsVector2Int.OnGUISlider();
            _prefsVector3Int.OnGUI();
            _prefsVector3Int.OnGUISlider();
            _prefsRect.OnGUI();
            _prefsRect.OnGUISlider();
            _prefsColor.OnGUI();


            _prefsIPEndPoint.OnGUI();

            // return true if value was changed
            if (_prefsColor.OnGUISlider())
            {
                // use as native type
                Color color = _prefsColor;
                Debug.Log("Changed. " + color);
            }


            // default OnGUI() is NOT user friendly. but PrefsList can save/load parametors.
            _prefsList.OnGUI();


            GUILayout.Label("PrefsListRuntimeGUI");
            GUIUtil.Indent(() =>
            {
                var list = _prefsListRuntimeGUI.Get();
                list.ForEach(customClass =>
                {
                    customClass.name     = GUILayout.TextField(customClass.name ?? "");
                    customClass.intValue = GUIUtil.IntButton(customClass.intValue);
                });
                using (var h = new GUILayout.HorizontalScope())
                {
                    if (GUILayout.Button("Add"))
                    {
                        list.Add(new CustomClass()
                        {
                            name = "Elem" + list.Count
                        });
                    }
                    if (GUILayout.Button("Remove"))
                    {
                        list.RemoveAt(list.Count - 1);
                    }

                    _prefsListRuntimeGUI.Set(list);
                    _prefsList.OnGUIDefaultButton();
                }
            });

            // if you use OnGUI. to set cumstomOnGUI is bettor.
            _prefsListCustomGUI.OnGUI();

            if (GUILayout.Button("Save"))
            {
                Prefs.Save();
            }
            if (GUILayout.Button("DeleteAll"))
            {
                Prefs.DeleteAll();
            }
        }
Exemplo n.º 4
0
        protected override void OnGUIInternal()
        {
            using (var h0 = 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 currentToDefaultEnable = !Application.isPlaying && PrefsList.Any(prefs => !prefs.IsDefault);

            GUI.enabled = currentToDefaultEnable;
            if (GUILayout.Button("Open Current To Default Window"))
            {
                if (setCurrentToDefaultWindow == null)
                {
                    setCurrentToDefaultWindow = CreateInstance <SetCurrentToDefaultWindow>();
                }
                setCurrentToDefaultWindow.parentWindow = this;
                setCurrentToDefaultWindow.ShowUtility();
            }
            GUI.enabled = true;

            GUILayout.Space(8f);

            using (var h = new GUILayout.HorizontalScope())
            {
                GUILayout.Label("Order");
                _order = (Order)GUILayout.SelectionGrid((int)_order, System.Enum.GetNames(typeof(Order)), 5);
            }

            GUILayout.Space(8f);

            using (var sc = new GUILayout.ScrollViewScope(scrollPosition))
            {
                scrollPosition = sc.scrollPosition;

                var sync = FindObjectOfType <PrefsGUISync>();
                if (sync != null)
                {
                    GUILayout.Label("sync");
                }


                if (Order.GameObject == _order)
                {
                    _goParams.Where(dic => dic.Key != null).OrderBy(dic => dic.Key.name).ToList().ForEach(pair =>
                    {
                        var go        = pair.Key;
                        var prefsList = pair.Value;

                        LabelWithEditPrefix(sync, go.name, go, prefsList);

                        GUIUtil.Indent(() =>
                        {
                            prefsList.ForEach(prefs =>
                            {
                                using (var h = new GUILayout.HorizontalScope())
                                {
                                    SyncToggle(sync, prefs);
                                    prefs.OnGUI();
                                }
                            });
                        });
                    });
                }
                else
                {
                    PrefsList.ToList().ForEach(prefs =>
                    {
                        using (var h = new GUILayout.HorizontalScope())
                        {
                            if (sync != null)
                            {
                                var key    = prefs.key;
                                var isSync = !sync._ignoreKeys.Contains(key);

                                if (isSync != GUILayout.Toggle(isSync, "", GUILayout.Width(16f)))
                                {
                                    Undo.RecordObject(sync, "Change PrefsGUI sync flag");

                                    if (isSync)
                                    {
                                        sync._ignoreKeys.Add(key);
                                    }
                                    else
                                    {
                                        sync._ignoreKeys.Remove(key);
                                    }
                                }
                            }

                            prefs.OnGUI();
                        }
                    });
                }
            }

            if ((setCurrentToDefaultWindow != null) && Event.current.type == EventType.Repaint)
            {
                setCurrentToDefaultWindow.Repaint();
            }
        }