private void OnDisable()
        {
            EditorLocalPrefs.Save(files[selectedFile]);
            EditorApplication.update -= Repaint;

            isInitialized = false;
        }
Ejemplo n.º 2
0
 public PrefGUI(string customLabel = null, string customValueName = null)
 {
     type        = typeof(T);
     label       = customLabel != null ? customLabel : type.Name;
     valueName   = customValueName != null ? customValueName : label;
     PN_collapse = script.GetType().Name + " " + type.Name + " Collapsed";
     collapse    = new AnimBool(window.Repaint)
     {
         speed = 3.5f, target = EditorLocalPrefs.GetBool(PN_collapse)
     };
     changes         = new List <Changes>();
     foundItemsCount = 0;
     nothingFound    = false;
     showItem        = new bool[0];
 }
        void Initialize()
        {
            FindSaveFiles(script.FilesPath);
            EditorLocalPrefs.Load(files[selectedFile]);

            EditorApplication.update += Repaint;

            prefGUIs.Clear();
            prefGUIs.Add(boolGUI    = new PrefGUI <bool>("Boolean"));
            prefGUIs.Add(intGUI     = new PrefGUI <int>("Int"));
            prefGUIs.Add(floatGUI   = new PrefGUI <float>("Float"));
            prefGUIs.Add(vector2GUI = new PrefGUI <Vector2>("Vector2"));
            prefGUIs.Add(vector3GUI = new PrefGUI <Vector3>("Vector3"));
            prefGUIs.Add(vector4GUI = new PrefGUI <Vector4>("Vector4"));
            prefGUIs.Add(stringGUI  = new PrefGUI <string>("String"));
        }
 private void OnEnable()
 {
     window        = this;
     isInitialized = false;
     script        = EditorLocalPrefs.Data;
 }
            public Prefs <T> DoLayout(Prefs <T> prefs)
            {
                string filter = searchFilter.ToLower();

                nothingFound = false;
                if (!searching)
                {
                    foundItemsCount = prefs.Count;
                }
                else
                {
                    showItem        = new bool[prefs.dictionary.Count];
                    foundItemsCount = 0;
                    int i = 0;
                    foreach (var value in prefs.dictionary)
                    {
                        if (value.Key.ToLower().Contains(filter))
                        {
                            showItem[i] = true;
                            foundItemsCount++;
                        }
                        i++;
                    }
                    nothingFound = foundItemsCount == 0;
                }
                if (window == null || script == null || nothingFound)
                {
                    return(prefs);
                }
                shownTypesCount++;
                changes.Clear();
                EditorGUILayout.BeginVertical(regionBg, GUILayout.MaxHeight(18));
                EditorGUILayout.BeginHorizontal();

                EditorGUI.BeginChangeCheck();
                collapse.target = GUILayout.Toggle(searching ? true : EditorLocalPrefs.GetBool(PN_collapse),
                                                   label, foldout, GUILayout.ExpandWidth(true));
                if (EditorGUI.EndChangeCheck())
                {
                    EditorLocalPrefs.SetBool(PN_collapse, collapse.target);
                }

                GUILayout.FlexibleSpace();
                GUILayout.Button("[" + foundItemsCount + "]", EditorStyles.centeredGreyMiniLabel);

                if (GUILayout.Button(new GUIContent("", !searching ? "Clear All" : "Remove Found Items"), "WinBtnCloseMac"))
                {
                    if (!searching)
                    {
                        prefs.ClearAll();
                    }
                    else
                    {
                        int i = 0;
                        foreach (var value in prefs.dictionary)
                        {
                            if (!showItem[i])
                            {
                                i++;
                                continue;
                            }
                            else
                            {
                                changes.Add(new Changes(value.Key, "", default, false, false, true, 0));
 public void Collapse()
 {
     EditorLocalPrefs.SetBool(PN_collapse, false);
 }
 public void Expand()
 {
     EditorLocalPrefs.SetBool(PN_collapse, true);
 }