Ejemplo n.º 1
0
 private void InitIfNeeded()
 {
     if (ColorPicker.styles == null)
     {
         ColorPicker.styles = new ColorPicker.Styles();
     }
     if (this.m_ColorLibraryEditorState == null)
     {
         this.m_ColorLibraryEditorState = new PresetLibraryEditorState(ColorPicker.presetsEditorPrefID);
         this.m_ColorLibraryEditorState.TransferEditorPrefsState(true);
     }
     if (this.m_ColorLibraryEditor == null)
     {
         ScriptableObjectSaveLoadHelper <ColorPresetLibrary> helper = new ScriptableObjectSaveLoadHelper <ColorPresetLibrary>("colors", SaveType.Text);
         this.m_ColorLibraryEditor = new PresetLibraryEditor <ColorPresetLibrary>(helper, this.m_ColorLibraryEditorState, new Action <int, object>(this.PresetClickedCallback));
         this.m_ColorLibraryEditor.previewAspect                       = 1f;
         this.m_ColorLibraryEditor.minMaxPreviewHeight                 = new Vector2(14f, 14f);
         this.m_ColorLibraryEditor.settingsMenuRightMargin             = 2f;
         this.m_ColorLibraryEditor.useOnePixelOverlappedGrid           = true;
         this.m_ColorLibraryEditor.alwaysShowScrollAreaHorizontalLines = false;
         this.m_ColorLibraryEditor.marginsForGrid                      = new RectOffset(0, 0, 0, 0);
         this.m_ColorLibraryEditor.marginsForList                      = new RectOffset(0, 5, 2, 2);
         this.m_ColorLibraryEditor.InitializeGrid(193f - (float)(ColorPicker.styles.background.padding.left + ColorPicker.styles.background.padding.right));
     }
 }
Ejemplo n.º 2
0
            static internal void Show(bool isOpenForEdit, int presetIndex, object newPresetObject, PresetLibraryEditor <T> caller)
            {
                s_Caller      = caller;
                s_PresetIndex = presetIndex;

                GUIContent replaceText = EditorGUIUtility.TrTextContent("Replace");
                GUIContent deleteText  = EditorGUIUtility.TrTextContent("Delete");
                GUIContent renameText  = EditorGUIUtility.TrTextContent("Rename");
                GUIContent moveToText  = EditorGUIUtility.TrTextContent("Move To First");

                GenericMenu menu = new GenericMenu();

                if (isOpenForEdit)
                {
                    menu.AddItem(replaceText, false, new PresetContextMenu().Replace, newPresetObject);
                    menu.AddItem(deleteText, false, new PresetContextMenu().Delete, 0);
                    if (caller.drawLabels)
                    {
                        menu.AddItem(renameText, false, new PresetContextMenu().Rename, 0);
                    }
                    menu.AddItem(moveToText, false, new PresetContextMenu().MoveToTop, 0);
                }
                else
                {
                    menu.AddDisabledItem(replaceText);
                    menu.AddDisabledItem(deleteText);
                    if (caller.drawLabels)
                    {
                        menu.AddDisabledItem(renameText);
                    }
                    menu.AddDisabledItem(moveToText);
                }
                menu.ShowAsContext();
            }
Ejemplo n.º 3
0
 private void CreateNewPresetButton(Rect buttonRect, object newPresetObject, PresetLibrary lib, bool isOpenForEdit)
 {
     EditorGUI.BeginDisabledGroup(!isOpenForEdit);
     if (GUI.Button(buttonRect, !isOpenForEdit ? PresetLibraryEditor <T> .s_Styles.plusButtonTextNotCheckedOut : PresetLibraryEditor <T> .s_Styles.plusButtonText))
     {
         int itemIndex = this.CreateNewPreset(newPresetObject, string.Empty);
         if (this.drawLabels)
         {
             this.BeginRenaming(string.Empty, itemIndex, 0f);
         }
         InspectorWindow.RepaintAllInspectors();
     }
     if (Event.current.type == EventType.Repaint)
     {
         Rect rect = new RectOffset(-3, -3, -3, -3).Add(buttonRect);
         lib.Draw(rect, newPresetObject);
         if (buttonRect.width > 30f)
         {
             PresetLibraryEditor <T> .LabelWithOutline(buttonRect, PresetLibraryEditor <T> .s_Styles.newPreset, new Color(0.1f, 0.1f, 0.1f), PresetLibraryEditor <T> .s_Styles.newPresetStyle);
         }
         else if ((lib.Count() == 0) && isOpenForEdit)
         {
             buttonRect.x      = buttonRect.xMax + 5f;
             buttonRect.width  = 200f;
             buttonRect.height = 16f;
             EditorGUI.BeginDisabledGroup(true);
             GUI.Label(buttonRect, "Click to add new preset");
             EditorGUI.EndDisabledGroup();
         }
     }
     EditorGUI.EndDisabledGroup();
 }
Ejemplo n.º 4
0
 public void InitIfNeeded()
 {
     if (this.m_CurveLibraryEditorState == null)
     {
         this.m_CurveLibraryEditorState = new PresetLibraryEditorState(this.GetEditorPrefBaseName());
         this.m_CurveLibraryEditorState.TransferEditorPrefsState(true);
     }
     if (this.m_CurveLibraryEditor == null)
     {
         ScriptableObjectSaveLoadHelper <DoubleCurvePresetLibrary> helper = new ScriptableObjectSaveLoadHelper <DoubleCurvePresetLibrary>(PresetLibraryLocations.GetParticleCurveLibraryExtension(this.m_DoubleCurve.IsSingleCurve(), this.m_DoubleCurve.signedRange), SaveType.Text);
         this.m_CurveLibraryEditor = new PresetLibraryEditor <DoubleCurvePresetLibrary>(helper, this.m_CurveLibraryEditorState, new Action <int, object>(this.ItemClickedCallback));
         this.m_CurveLibraryEditor.addDefaultPresets   = (Action <PresetLibrary>)Delegate.Combine(this.m_CurveLibraryEditor.addDefaultPresets, new Action <PresetLibrary>(this.AddDefaultPresetsToLibrary));
         this.m_CurveLibraryEditor.presetsWasReordered = new Action(this.PresetsWasReordered);
         this.m_CurveLibraryEditor.previewAspect       = 4f;
         this.m_CurveLibraryEditor.minMaxPreviewHeight = new Vector2(24f, 24f);
         this.m_CurveLibraryEditor.showHeader          = true;
     }
 }
 public void InitIfNeeded()
 {
     if (this.m_CurveLibraryEditorState == null)
     {
         this.m_CurveLibraryEditorState = new PresetLibraryEditorState(CurvePresetsContentsForPopupWindow.GetBasePrefText(this.m_CurveLibraryType));
         this.m_CurveLibraryEditorState.TransferEditorPrefsState(true);
     }
     if (this.m_CurveLibraryEditor != null)
     {
         return;
     }
     this.m_CurveLibraryEditor = new PresetLibraryEditor <CurvePresetLibrary>(new ScriptableObjectSaveLoadHelper <CurvePresetLibrary>(CurvePresetsContentsForPopupWindow.GetExtension(this.m_CurveLibraryType), SaveType.Text), this.m_CurveLibraryEditorState, new System.Action <int, object>(this.ItemClickedCallback));
     this.m_CurveLibraryEditor.addDefaultPresets   += new System.Action <PresetLibrary>(this.AddDefaultPresetsToLibrary);
     this.m_CurveLibraryEditor.presetsWasReordered += new System.Action(this.OnPresetsWasReordered);
     this.m_CurveLibraryEditor.previewAspect        = 4f;
     this.m_CurveLibraryEditor.minMaxPreviewHeight  = new Vector2(24f, 24f);
     this.m_CurveLibraryEditor.showHeader           = true;
 }
 public void InitIfNeeded()
 {
     if (this.m_CurveLibraryEditorState == null)
     {
         this.m_CurveLibraryEditorState = new PresetLibraryEditorState(GetBasePrefText(this.m_CurveLibraryType));
         this.m_CurveLibraryEditorState.TransferEditorPrefsState(true);
     }
     if (this.m_CurveLibraryEditor == null)
     {
         ScriptableObjectSaveLoadHelper <CurvePresetLibrary> helper = new ScriptableObjectSaveLoadHelper <CurvePresetLibrary>(GetExtension(this.m_CurveLibraryType), SaveType.Text);
         this.m_CurveLibraryEditor = new PresetLibraryEditor <CurvePresetLibrary>(helper, this.m_CurveLibraryEditorState, new Action <int, object>(this.ItemClickedCallback));
         this.m_CurveLibraryEditor.addDefaultPresets   = (Action <PresetLibrary>)Delegate.Combine(this.m_CurveLibraryEditor.addDefaultPresets, new Action <PresetLibrary>(this.AddDefaultPresetsToLibrary));
         this.m_CurveLibraryEditor.presetsWasReordered = (Action)Delegate.Combine(this.m_CurveLibraryEditor.presetsWasReordered, new Action(this.OnPresetsWasReordered));
         this.m_CurveLibraryEditor.previewAspect       = 4f;
         this.m_CurveLibraryEditor.minMaxPreviewHeight = new Vector2(24f, 24f);
         this.m_CurveLibraryEditor.showHeader          = true;
     }
 }
        public void InitIfNeeded()
        {
            if (m_CurveLibraryEditorState == null)
            {
                m_CurveLibraryEditorState = new PresetLibraryEditorState(GetBasePrefText(m_CurveLibraryType));
                m_CurveLibraryEditorState.TransferEditorPrefsState(true);
            }

            if (m_CurveLibraryEditor == null)
            {
                var saveLoadHelper = new ScriptableObjectSaveLoadHelper <CurvePresetLibrary>(GetExtension(m_CurveLibraryType), SaveType.Text);
                m_CurveLibraryEditor = new PresetLibraryEditor <CurvePresetLibrary>(saveLoadHelper, m_CurveLibraryEditorState, ItemClickedCallback);
                m_CurveLibraryEditor.addDefaultPresets   += AddDefaultPresetsToLibrary;
                m_CurveLibraryEditor.presetsWasReordered += OnPresetsWasReordered;
                m_CurveLibraryEditor.previewAspect        = 4f;
                m_CurveLibraryEditor.minMaxPreviewHeight  = new Vector2(24f, 24f);
                m_CurveLibraryEditor.showHeader           = true;
            }
        }
        public void InitIfNeeded()
        {
            if (m_CurveLibraryEditorState == null)
            {
                m_CurveLibraryEditorState = new PresetLibraryEditorState(GetEditorPrefBaseName());
                m_CurveLibraryEditorState.TransferEditorPrefsState(true);
            }

            if (m_CurveLibraryEditor == null)
            {
                var extension      = PresetLibraryLocations.GetParticleCurveLibraryExtension(m_DoubleCurve.IsSingleCurve(), m_DoubleCurve.signedRange);
                var saveLoadHelper = new ScriptableObjectSaveLoadHelper <DoubleCurvePresetLibrary>(extension, SaveType.Text);
                m_CurveLibraryEditor = new PresetLibraryEditor <DoubleCurvePresetLibrary>(saveLoadHelper, m_CurveLibraryEditorState, ItemClickedCallback);
                m_CurveLibraryEditor.addDefaultPresets  += AddDefaultPresetsToLibrary;
                m_CurveLibraryEditor.presetsWasReordered = PresetsWasReordered;
                m_CurveLibraryEditor.previewAspect       = 4f;
                m_CurveLibraryEditor.minMaxPreviewHeight = new Vector2(24f, 24f);
                m_CurveLibraryEditor.showHeader          = true;
            }
        }
Ejemplo n.º 9
0
 private void InitIfNeeded()
 {
     if (this.m_GradientEditor == null)
     {
         this.m_GradientEditor = new GradientEditor();
         this.m_GradientEditor.Init(this.m_Gradient, 0);
     }
     if (this.m_GradientLibraryEditorState == null)
     {
         this.m_GradientLibraryEditorState = new PresetLibraryEditorState(GradientPicker.presetsEditorPrefID);
         this.m_GradientLibraryEditorState.TransferEditorPrefsState(true);
     }
     if (this.m_GradientLibraryEditor != null)
     {
         return;
     }
     this.m_GradientLibraryEditor                     = new PresetLibraryEditor <GradientPresetLibrary>(new ScriptableObjectSaveLoadHelper <GradientPresetLibrary>("gradients", SaveType.Text), this.m_GradientLibraryEditorState, new System.Action <int, object>(this.PresetClickedCallback));
     this.m_GradientLibraryEditor.showHeader          = true;
     this.m_GradientLibraryEditor.minMaxPreviewHeight = new Vector2(14f, 14f);
 }
Ejemplo n.º 10
0
        void InitIfNeeded()
        {
            // Init editor when needed
            if (m_GradientEditor == null)
            {
                m_GradientEditor = new GradientEditor();
                m_GradientEditor.Init(m_Gradient, k_DefaultNumSteps, m_HDR);
            }

            if (m_GradientLibraryEditorState == null)
            {
                m_GradientLibraryEditorState = new PresetLibraryEditorState(presetsEditorPrefID);
                m_GradientLibraryEditorState.TransferEditorPrefsState(true);
            }

            if (m_GradientLibraryEditor == null)
            {
                var saveLoadHelper = new ScriptableObjectSaveLoadHelper <GradientPresetLibrary>("gradients", SaveType.Text);
                m_GradientLibraryEditor                     = new PresetLibraryEditor <GradientPresetLibrary>(saveLoadHelper, m_GradientLibraryEditorState, PresetClickedCallback);
                m_GradientLibraryEditor.showHeader          = true;
                m_GradientLibraryEditor.minMaxPreviewHeight = new Vector2(14f, 14f);
            }
        }
Ejemplo n.º 11
0
            internal static void Show(bool isOpenForEdit, int presetIndex, object newPresetObject, PresetLibraryEditor <T> caller)
            {
                PresetLibraryEditor <T> .PresetContextMenu.s_Caller      = caller;
                PresetLibraryEditor <T> .PresetContextMenu.s_PresetIndex = presetIndex;
                GUIContent  content  = new GUIContent("Replace");
                GUIContent  content2 = new GUIContent("Delete");
                GUIContent  content3 = new GUIContent("Rename");
                GUIContent  content4 = new GUIContent("Move To First");
                GenericMenu menu     = new GenericMenu();

                if (isOpenForEdit)
                {
                    menu.AddItem(content, false, new GenericMenu.MenuFunction2(new PresetLibraryEditor <T> .PresetContextMenu().Replace), newPresetObject);
                    menu.AddItem(content2, false, new GenericMenu.MenuFunction2(new PresetLibraryEditor <T> .PresetContextMenu().Delete), 0);
                    if (caller.drawLabels)
                    {
                        menu.AddItem(content3, false, new GenericMenu.MenuFunction2(new PresetLibraryEditor <T> .PresetContextMenu().Rename), 0);
                    }
                    menu.AddItem(content4, false, new GenericMenu.MenuFunction2(new PresetLibraryEditor <T> .PresetContextMenu().MoveToTop), 0);
                }
                else
                {
                    menu.AddDisabledItem(content);
                    menu.AddDisabledItem(content2);
                    if (caller.drawLabels)
                    {
                        menu.AddDisabledItem(content3);
                    }
                    menu.AddDisabledItem(content4);
                }
                menu.ShowAsContext();
            }
Ejemplo n.º 12
0
            public static void Show(Rect activatorRect, PresetLibraryEditor <T> owner)
            {
                List <ViewModeData <T> > list;
                List <string>            list2;
                List <string>            list3;
                List <ViewModeData <T> > list4;
                ViewModeData <T>         data;

                PresetLibraryEditor <T> .SettingsMenu.s_Owner = owner;
                GenericMenu menu = new GenericMenu();
                int         x    = (int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.minMaxPreviewHeight.x;
                int         y    = (int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.minMaxPreviewHeight.y;

                if (x == y)
                {
                    list4 = new List <ViewModeData <T> >();
                    data  = new ViewModeData <T> {
                        text       = new GUIContent("Grid"),
                        itemHeight = x,
                        viewmode   = PresetLibraryEditorState.ItemViewMode.Grid
                    };
                    list4.Add(data);
                    data = new ViewModeData <T> {
                        text       = new GUIContent("List"),
                        itemHeight = x,
                        viewmode   = PresetLibraryEditorState.ItemViewMode.List
                    };
                    list4.Add(data);
                    list = list4;
                }
                else
                {
                    list4 = new List <ViewModeData <T> >();
                    data  = new ViewModeData <T> {
                        text       = new GUIContent("Small Grid"),
                        itemHeight = x,
                        viewmode   = PresetLibraryEditorState.ItemViewMode.Grid
                    };
                    list4.Add(data);
                    data = new ViewModeData <T> {
                        text       = new GUIContent("Large Grid"),
                        itemHeight = y,
                        viewmode   = PresetLibraryEditorState.ItemViewMode.Grid
                    };
                    list4.Add(data);
                    data = new ViewModeData <T> {
                        text       = new GUIContent("Small List"),
                        itemHeight = x,
                        viewmode   = PresetLibraryEditorState.ItemViewMode.List
                    };
                    list4.Add(data);
                    data = new ViewModeData <T> {
                        text       = new GUIContent("Large List"),
                        itemHeight = y,
                        viewmode   = PresetLibraryEditorState.ItemViewMode.List
                    };
                    list4.Add(data);
                    list = list4;
                }
                for (int i = 0; i < list.Count; i++)
                {
                    bool on = (PresetLibraryEditor <T> .SettingsMenu.s_Owner.itemViewMode == list[i].viewmode) && (((int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.previewHeight) == list[i].itemHeight);
                    menu.AddItem(list[i].text, on, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.ViewModeChange), list[i]);
                }
                menu.AddSeparator(string.Empty);
                ScriptableSingleton <PresetLibraryManager> .instance.GetAvailableLibraries <T>(PresetLibraryEditor <T> .SettingsMenu.s_Owner.m_SaveLoadHelper, out list2, out list3);

                list2.Sort();
                list3.Sort();
                string str  = PresetLibraryEditor <T> .SettingsMenu.s_Owner.currentLibraryWithoutExtension + "." + PresetLibraryEditor <T> .SettingsMenu.s_Owner.m_SaveLoadHelper.fileExtensionWithoutDot;
                string str2 = " (Project)";

                foreach (string str3 in list2)
                {
                    string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(str3);
                    menu.AddItem(new GUIContent(fileNameWithoutExtension), str == str3, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.LibraryModeChange), str3);
                }
                foreach (string str5 in list3)
                {
                    string str6 = Path.GetFileNameWithoutExtension(str5);
                    menu.AddItem(new GUIContent(str6 + str2), str == str5, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.LibraryModeChange), str5);
                }
                menu.AddSeparator(string.Empty);
                menu.AddItem(new GUIContent("Create New Library..."), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.CreateLibrary), 0);
                if (PresetLibraryEditor <T> .SettingsMenu.HasDefaultPresets())
                {
                    menu.AddSeparator(string.Empty);
                    menu.AddItem(new GUIContent("Add Factory Presets To Current Library"), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.AddDefaultPresetsToCurrentLibrary), 0);
                }
                menu.AddSeparator(string.Empty);
                menu.AddItem(new GUIContent("Reveal Current Library Location"), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.RevealCurrentLibrary), 0);
                menu.DropDown(activatorRect);
            }
Ejemplo n.º 13
0
 private static void ViewModeChange(object userData)
 {
     PresetLibraryEditor <T> .SettingsMenu.ViewModeData viewModeData = (PresetLibraryEditor <T> .SettingsMenu.ViewModeData)userData;
     PresetLibraryEditor <T> .SettingsMenu.s_Owner.itemViewMode  = viewModeData.viewmode;
     PresetLibraryEditor <T> .SettingsMenu.s_Owner.previewHeight = (float)viewModeData.itemHeight;
 }
Ejemplo n.º 14
0
            public static void Show(Rect activatorRect, PresetLibraryEditor <T> owner)
            {
                PresetLibraryEditor <T> .SettingsMenu.s_Owner = owner;
                GenericMenu genericMenu = new GenericMenu();
                int         x           = (int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.minMaxPreviewHeight.x;
                int         y           = (int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.minMaxPreviewHeight.y;
                List <PresetLibraryEditor <T> .SettingsMenu.ViewModeData> viewModeDataList;

                if (x == y)
                {
                    viewModeDataList = new List <PresetLibraryEditor <T> .SettingsMenu.ViewModeData>()
                    {
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData()
                        {
                            text       = new GUIContent("Grid"),
                            itemHeight = x,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.Grid
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData()
                        {
                            text       = new GUIContent("List"),
                            itemHeight = x,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.List
                        }
                    }
                }
                ;
                else
                {
                    viewModeDataList = new List <PresetLibraryEditor <T> .SettingsMenu.ViewModeData>()
                    {
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData()
                        {
                            text       = new GUIContent("Small Grid"),
                            itemHeight = x,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.Grid
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData()
                        {
                            text       = new GUIContent("Large Grid"),
                            itemHeight = y,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.Grid
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData()
                        {
                            text       = new GUIContent("Small List"),
                            itemHeight = x,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.List
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData()
                        {
                            text       = new GUIContent("Large List"),
                            itemHeight = y,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.List
                        }
                    }
                };
                for (int index = 0; index < viewModeDataList.Count; ++index)
                {
                    bool on = PresetLibraryEditor <T> .SettingsMenu.s_Owner.itemViewMode == viewModeDataList[index].viewmode && (int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.previewHeight == viewModeDataList[index].itemHeight;
                    genericMenu.AddItem(viewModeDataList[index].text, on, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.ViewModeChange), (object)viewModeDataList[index]);
                }
                genericMenu.AddSeparator(string.Empty);
                List <string> preferencesLibs;
                List <string> projectLibs;

                ScriptableSingleton <PresetLibraryManager> .instance.GetAvailableLibraries <T>(PresetLibraryEditor <T> .SettingsMenu.s_Owner.m_SaveLoadHelper, out preferencesLibs, out projectLibs);

                preferencesLibs.Sort();
                projectLibs.Sort();
                string str1 = PresetLibraryEditor <T> .SettingsMenu.s_Owner.currentLibraryWithoutExtension + "." + PresetLibraryEditor <T> .SettingsMenu.s_Owner.m_SaveLoadHelper.fileExtensionWithoutDot;
                string str2 = " (Project)";

                using (List <string> .Enumerator enumerator = preferencesLibs.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        string current          = enumerator.Current;
                        string withoutExtension = Path.GetFileNameWithoutExtension(current);
                        genericMenu.AddItem(new GUIContent(withoutExtension), str1 == current, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.LibraryModeChange), (object)current);
                    }
                }
                using (List <string> .Enumerator enumerator = projectLibs.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        string current          = enumerator.Current;
                        string withoutExtension = Path.GetFileNameWithoutExtension(current);
                        genericMenu.AddItem(new GUIContent(withoutExtension + str2), str1 == current, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.LibraryModeChange), (object)current);
                    }
                }
                genericMenu.AddSeparator(string.Empty);
                genericMenu.AddItem(new GUIContent("Create New Library..."), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.CreateLibrary), (object)0);
                if (PresetLibraryEditor <T> .SettingsMenu.HasDefaultPresets())
                {
                    genericMenu.AddSeparator(string.Empty);
                    genericMenu.AddItem(new GUIContent("Add Factory Presets To Current Library"), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.AddDefaultPresetsToCurrentLibrary), (object)0);
                }
                genericMenu.AddSeparator(string.Empty);
                genericMenu.AddItem(new GUIContent("Reveal Current Library Location"), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.RevealCurrentLibrary), (object)0);
                genericMenu.DropDown(activatorRect);
            }
Ejemplo n.º 15
0
            public static void Show(Rect activatorRect, PresetLibraryEditor <T> owner)
            {
                PresetLibraryEditor <T> .SettingsMenu.s_Owner = owner;
                GenericMenu genericMenu = new GenericMenu();
                int         num         = (int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.minMaxPreviewHeight.x;
                int         num2        = (int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.minMaxPreviewHeight.y;
                List <PresetLibraryEditor <T> .SettingsMenu.ViewModeData> list;

                if (num == num2)
                {
                    list = new List <PresetLibraryEditor <T> .SettingsMenu.ViewModeData>
                    {
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData
                        {
                            text       = new GUIContent("Grid"),
                            itemHeight = num
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData
                        {
                            text       = new GUIContent("List"),
                            itemHeight = num,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.List
                        }
                    };
                }
                else
                {
                    list = new List <PresetLibraryEditor <T> .SettingsMenu.ViewModeData>
                    {
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData
                        {
                            text       = new GUIContent("Small Grid"),
                            itemHeight = num
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData
                        {
                            text       = new GUIContent("Large Grid"),
                            itemHeight = num2
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData
                        {
                            text       = new GUIContent("Small List"),
                            itemHeight = num,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.List
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData
                        {
                            text       = new GUIContent("Large List"),
                            itemHeight = num2,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.List
                        }
                    };
                }
                for (int i = 0; i < list.Count; i++)
                {
                    bool on = PresetLibraryEditor <T> .SettingsMenu.s_Owner.itemViewMode == list[i].viewmode && (int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.previewHeight == list[i].itemHeight;
                    genericMenu.AddItem(list[i].text, on, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.ViewModeChange), list[i]);
                }
                genericMenu.AddSeparator(string.Empty);
                List <string> list2;
                List <string> list3;

                ScriptableSingleton <PresetLibraryManager> .instance.GetAvailableLibraries <T>(PresetLibraryEditor <T> .SettingsMenu.s_Owner.m_SaveLoadHelper, out list2, out list3);

                list2.Sort();
                list3.Sort();
                string a   = PresetLibraryEditor <T> .SettingsMenu.s_Owner.currentLibraryWithoutExtension + "." + PresetLibraryEditor <T> .SettingsMenu.s_Owner.m_SaveLoadHelper.fileExtensionWithoutDot;
                string str = " (Project)";

                foreach (string current in list2)
                {
                    string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(current);
                    genericMenu.AddItem(new GUIContent(fileNameWithoutExtension), a == current, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.LibraryModeChange), current);
                }
                foreach (string current2 in list3)
                {
                    string fileNameWithoutExtension2 = Path.GetFileNameWithoutExtension(current2);
                    genericMenu.AddItem(new GUIContent(fileNameWithoutExtension2 + str), a == current2, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.LibraryModeChange), current2);
                }
                genericMenu.AddSeparator(string.Empty);
                genericMenu.AddItem(new GUIContent("Create New Library..."), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.CreateLibrary), 0);
                if (PresetLibraryEditor <T> .SettingsMenu.HasDefaultPresets())
                {
                    genericMenu.AddSeparator(string.Empty);
                    genericMenu.AddItem(new GUIContent("Add Factory Presets To Current Library"), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.AddDefaultPresetsToCurrentLibrary), 0);
                }
                genericMenu.AddSeparator(string.Empty);
                genericMenu.AddItem(new GUIContent("Reveal Current Library Location"), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.RevealCurrentLibrary), 0);
                genericMenu.DropDown(activatorRect);
            }
            public static void Show(Rect activatorRect, PresetLibraryEditor <T> owner)
            {
                s_Owner = owner;

                GenericMenu menu = new GenericMenu();

                // View modes
                int minItemHeight = (int)s_Owner.minMaxPreviewHeight.x;
                int maxItemHeight = (int)s_Owner.minMaxPreviewHeight.y;
                List <ViewModeData> viewModeData;

                if (minItemHeight == maxItemHeight)
                {
                    viewModeData = new List <ViewModeData>
                    {
                        new ViewModeData {
                            text = EditorGUIUtility.TrTextContent("Grid"), itemHeight = minItemHeight, viewmode = PresetLibraryEditorState.ItemViewMode.Grid
                        },
                        new ViewModeData {
                            text = EditorGUIUtility.TrTextContent("List"), itemHeight = minItemHeight, viewmode = PresetLibraryEditorState.ItemViewMode.List
                        },
                    };
                }
                else
                {
                    viewModeData = new List <ViewModeData>
                    {
                        new ViewModeData {
                            text = EditorGUIUtility.TrTextContent("Small Grid"), itemHeight = minItemHeight, viewmode = PresetLibraryEditorState.ItemViewMode.Grid
                        },
                        new ViewModeData {
                            text = EditorGUIUtility.TrTextContent("Large Grid"), itemHeight = maxItemHeight, viewmode = PresetLibraryEditorState.ItemViewMode.Grid
                        },
                        new ViewModeData {
                            text = EditorGUIUtility.TrTextContent("Small List"), itemHeight = minItemHeight, viewmode = PresetLibraryEditorState.ItemViewMode.List
                        },
                        new ViewModeData {
                            text = EditorGUIUtility.TrTextContent("Large List"), itemHeight = maxItemHeight, viewmode = PresetLibraryEditorState.ItemViewMode.List
                        }
                    };
                }

                for (int i = 0; i < viewModeData.Count; ++i)
                {
                    bool currentSelected = s_Owner.itemViewMode == viewModeData[i].viewmode && (int)s_Owner.previewHeight == viewModeData[i].itemHeight;
                    menu.AddItem(viewModeData[i].text, currentSelected, ViewModeChange, viewModeData[i]);
                }
                menu.AddSeparator("");

                // Available libraries (show user libraries first then project libraries)
                List <string> preferencesLibs;
                List <string> projectLibs;

                PresetLibraryManager.instance.GetAvailableLibraries(s_Owner.m_SaveLoadHelper, out preferencesLibs, out projectLibs);
                preferencesLibs.Sort();
                projectLibs.Sort();

                string currentLibWithExtension = s_Owner.currentLibraryWithoutExtension + "." + s_Owner.m_SaveLoadHelper.fileExtensionWithoutDot;

                string projectFolderTag = " (Project)";

                foreach (string libPath in preferencesLibs)
                {
                    string libName = Path.GetFileNameWithoutExtension(libPath);
                    menu.AddItem(new GUIContent(libName), currentLibWithExtension == libPath, LibraryModeChange, libPath);
                }
                foreach (string libPath in projectLibs)
                {
                    string libName = Path.GetFileNameWithoutExtension(libPath);
                    menu.AddItem(new GUIContent(libName + projectFolderTag), currentLibWithExtension == libPath, LibraryModeChange, libPath);
                }
                menu.AddSeparator("");
                menu.AddItem(EditorGUIUtility.TrTextContent("Create New Library..."), false, CreateLibrary, 0);
                if (HasDefaultPresets())
                {
                    menu.AddSeparator("");
                    menu.AddItem(EditorGUIUtility.TrTextContent("Add Factory Presets To Current Library"), false, AddDefaultPresetsToCurrentLibrary, 0);
                }
                menu.AddSeparator("");
                menu.AddItem(EditorGUIUtility.TrTextContent("Reveal Current Library Location"), false, RevealCurrentLibrary, 0);
                menu.DropDown(activatorRect);
            }