예제 #1
0
        public GenericPresetLibraryInspector(UnityEngine.Object target, string header, Action <string> editButtonClicked)
        {
            this.m_Target = target;
            this.m_Header = header;
            this.m_EditButtonClickedCallback = editButtonClicked;
            string assetPath = AssetDatabase.GetAssetPath(this.m_Target.GetInstanceID());
            string text      = Path.GetExtension(assetPath);

            if (!string.IsNullOrEmpty(text))
            {
                text = text.TrimStart(new char[]
                {
                    '.'
                });
            }
            this.m_SaveLoadHelper          = new ScriptableObjectSaveLoadHelper <T>(text, SaveType.Text);
            this.m_Grid                    = new VerticalGrid();
            this.maxShowNumPresets         = 49;
            this.presetSize                = new Vector2(14f, 14f);
            this.lineSpacing               = 1f;
            this.useOnePixelOverlappedGrid = false;
            this.marginsForList            = new RectOffset(10, 10, 5, 5);
            this.marginsForGrid            = new RectOffset(10, 10, 5, 5);
            this.itemViewMode              = PresetLibraryEditorState.ItemViewMode.List;
        }
예제 #2
0
        private void SetupGrid(float availableWidth, int itemCount, PresetLibraryEditorState.ItemViewMode presetsViewMode)
        {
            this.m_Grid.useFixedHorizontalSpacing = this.useOnePixelOverlappedGrid;
            this.m_Grid.fixedHorizontalSpacing    = !this.useOnePixelOverlappedGrid ? ((float)0) : ((float)(-1));
            switch (presetsViewMode)
            {
            case PresetLibraryEditorState.ItemViewMode.Grid:
                this.m_Grid.fixedWidth           = availableWidth;
                this.m_Grid.topMargin            = this.marginsForGrid.top;
                this.m_Grid.bottomMargin         = this.marginsForGrid.bottom;
                this.m_Grid.leftMargin           = this.marginsForGrid.left;
                this.m_Grid.rightMargin          = this.marginsForGrid.right;
                this.m_Grid.verticalSpacing      = !this.useOnePixelOverlappedGrid ? this.lineSpacing : -1f;
                this.m_Grid.minHorizontalSpacing = 8f;
                this.m_Grid.itemSize             = this.presetSize;
                this.m_Grid.InitNumRowsAndColumns(itemCount, 0x7fffffff);
                break;

            case PresetLibraryEditorState.ItemViewMode.List:
                this.m_Grid.fixedWidth           = availableWidth;
                this.m_Grid.topMargin            = this.marginsForList.top;
                this.m_Grid.bottomMargin         = this.marginsForList.bottom;
                this.m_Grid.leftMargin           = this.marginsForList.left;
                this.m_Grid.rightMargin          = this.marginsForList.right;
                this.m_Grid.verticalSpacing      = this.lineSpacing;
                this.m_Grid.minHorizontalSpacing = 0f;
                this.m_Grid.itemSize             = new Vector2(availableWidth - this.m_Grid.leftMargin, this.presetSize.y);
                this.m_Grid.InitNumRowsAndColumns(itemCount, 0x7fffffff);
                break;
            }
        }
예제 #3
0
 private void SetupGrid(float availableWidth, int itemCount, PresetLibraryEditorState.ItemViewMode presetsViewMode)
 {
     this.m_Grid.useFixedHorizontalSpacing = this.useOnePixelOverlappedGrid;
     this.m_Grid.fixedHorizontalSpacing    = (float)((!this.useOnePixelOverlappedGrid) ? 0 : -1);
     if (presetsViewMode != PresetLibraryEditorState.ItemViewMode.Grid)
     {
         if (presetsViewMode == PresetLibraryEditorState.ItemViewMode.List)
         {
             this.m_Grid.fixedWidth           = availableWidth;
             this.m_Grid.topMargin            = (float)this.marginsForList.top;
             this.m_Grid.bottomMargin         = (float)this.marginsForList.bottom;
             this.m_Grid.leftMargin           = (float)this.marginsForList.left;
             this.m_Grid.rightMargin          = (float)this.marginsForList.right;
             this.m_Grid.verticalSpacing      = this.lineSpacing;
             this.m_Grid.minHorizontalSpacing = 0f;
             this.m_Grid.itemSize             = new Vector2(availableWidth - this.m_Grid.leftMargin, this.presetSize.y);
             this.m_Grid.InitNumRowsAndColumns(itemCount, 2147483647);
         }
     }
     else
     {
         this.m_Grid.fixedWidth           = availableWidth;
         this.m_Grid.topMargin            = (float)this.marginsForGrid.top;
         this.m_Grid.bottomMargin         = (float)this.marginsForGrid.bottom;
         this.m_Grid.leftMargin           = (float)this.marginsForGrid.left;
         this.m_Grid.rightMargin          = (float)this.marginsForGrid.right;
         this.m_Grid.verticalSpacing      = ((!this.useOnePixelOverlappedGrid) ? this.lineSpacing : -1f);
         this.m_Grid.minHorizontalSpacing = 8f;
         this.m_Grid.itemSize             = this.presetSize;
         this.m_Grid.InitNumRowsAndColumns(itemCount, 2147483647);
     }
 }
        public GenericPresetLibraryInspector(UnityEngine.Object target, string header, Action <string> editButtonClicked)
        {
            m_Target = target;
            m_Header = header;
            m_EditButtonClickedCallback = editButtonClicked;

            string assetPath = AssetDatabase.GetAssetPath(m_Target.GetInstanceID());
            string extension = Path.GetExtension(assetPath);

            if (!string.IsNullOrEmpty(extension))
            {
                extension = extension.TrimStart('.');
            }
            m_SaveLoadHelper = new ScriptableObjectSaveLoadHelper <T>(extension, SaveType.Text);
            m_Grid           = new VerticalGrid();

            // Default configuration
            maxShowNumPresets         = 49; // We clear some preview caches when they reach 50 (See AnimationCurvePreviewCache and GradientPreviewCache)
            presetSize                = new Vector2(14, 14);
            lineSpacing               = 1f;
            useOnePixelOverlappedGrid = false;
            marginsForList            = new RectOffset(10, 10, 5, 5);
            marginsForGrid            = new RectOffset(10, 10, 5, 5);
            itemViewMode              = PresetLibraryEditorState.ItemViewMode.List;
        }
        void SetupGrid(float availableWidth, int itemCount, PresetLibraryEditorState.ItemViewMode presetsViewMode)
        {
            m_Grid.useFixedHorizontalSpacing = useOnePixelOverlappedGrid;
            m_Grid.fixedHorizontalSpacing    = useOnePixelOverlappedGrid ? -1 : 0;

            switch (presetsViewMode)
            {
            case PresetLibraryEditorState.ItemViewMode.Grid:
                m_Grid.fixedWidth           = availableWidth;
                m_Grid.topMargin            = marginsForGrid.top;
                m_Grid.bottomMargin         = marginsForGrid.bottom;
                m_Grid.leftMargin           = marginsForGrid.left;
                m_Grid.rightMargin          = marginsForGrid.right;
                m_Grid.verticalSpacing      = useOnePixelOverlappedGrid ? -1 : lineSpacing;
                m_Grid.minHorizontalSpacing = 8f;
                m_Grid.itemSize             = presetSize; // no text
                m_Grid.InitNumRowsAndColumns(itemCount, int.MaxValue);
                break;

            case PresetLibraryEditorState.ItemViewMode.List:
                m_Grid.fixedWidth           = availableWidth;
                m_Grid.topMargin            = marginsForList.top;
                m_Grid.bottomMargin         = marginsForList.bottom;
                m_Grid.leftMargin           = marginsForList.left;
                m_Grid.rightMargin          = marginsForList.right;
                m_Grid.verticalSpacing      = lineSpacing;
                m_Grid.minHorizontalSpacing = 0f;
                m_Grid.itemSize             = new Vector2(availableWidth - m_Grid.leftMargin, presetSize.y);
                m_Grid.InitNumRowsAndColumns(itemCount, int.MaxValue);
                break;
            }
        }
예제 #6
0
        private void SetupGrid(float width, int itemCount)
        {
            if (width < 1f)
            {
                Debug.LogError(string.Concat(new object[]
                {
                    "Invalid width ",
                    width,
                    ", ",
                    Event.current.type
                }));
                return;
            }
            if (this.m_ShowAddNewPresetItem)
            {
                itemCount++;
            }
            this.m_Grid.useFixedHorizontalSpacing = this.useOnePixelOverlappedGrid;
            this.m_Grid.fixedHorizontalSpacing    = (float)((!this.useOnePixelOverlappedGrid) ? 0 : -1);
            PresetLibraryEditorState.ItemViewMode itemViewMode = this.m_State.itemViewMode;
            if (itemViewMode != PresetLibraryEditorState.ItemViewMode.Grid)
            {
                if (itemViewMode == PresetLibraryEditorState.ItemViewMode.List)
                {
                    this.m_Grid.fixedWidth           = width;
                    this.m_Grid.topMargin            = (float)this.marginsForList.top;
                    this.m_Grid.bottomMargin         = (float)this.marginsForList.bottom;
                    this.m_Grid.leftMargin           = (float)this.marginsForList.left;
                    this.m_Grid.rightMargin          = (float)this.marginsForList.right;
                    this.m_Grid.verticalSpacing      = 2f;
                    this.m_Grid.minHorizontalSpacing = 0f;
                    this.m_Grid.itemSize             = new Vector2(width - this.m_Grid.leftMargin, this.m_State.m_PreviewHeight);
                    this.m_Grid.InitNumRowsAndColumns(itemCount, 2147483647);
                }
            }
            else
            {
                this.m_Grid.fixedWidth           = width;
                this.m_Grid.topMargin            = (float)this.marginsForGrid.top;
                this.m_Grid.bottomMargin         = (float)this.marginsForGrid.bottom;
                this.m_Grid.leftMargin           = (float)this.marginsForGrid.left;
                this.m_Grid.rightMargin          = (float)this.marginsForGrid.right;
                this.m_Grid.verticalSpacing      = (float)((!this.useOnePixelOverlappedGrid) ? 2 : -1);
                this.m_Grid.minHorizontalSpacing = 1f;
                this.m_Grid.itemSize             = new Vector2(this.m_State.m_PreviewHeight * this.m_PreviewAspect, this.m_State.m_PreviewHeight);
                this.m_Grid.InitNumRowsAndColumns(itemCount, 2147483647);
            }
            float num = this.m_Grid.CalcRect(itemCount - 1, 0f).yMax + this.m_Grid.bottomMargin;

            this.contentHeight = this.topAreaHeight + num + ((!this.m_IsOpenForEdit) ? this.versionControlAreaHeight : 0f);
        }
 public void TransferEditorPrefsState(bool load)
 {
   if (load)
   {
     this.m_ItemViewMode = (PresetLibraryEditorState.ItemViewMode) EditorPrefs.GetInt(this.m_Prefix + "ViewMode", (int) this.m_ItemViewMode);
     this.m_PreviewHeight = EditorPrefs.GetFloat(this.m_Prefix + "ItemHeight", this.m_PreviewHeight);
     this.m_ScrollPosition.y = EditorPrefs.GetFloat(this.m_Prefix + "Scroll", this.m_ScrollPosition.y);
     this.m_CurrrentLibrary = EditorPrefs.GetString(this.m_Prefix + "CurrentLib", this.m_CurrrentLibrary);
   }
   else
   {
     EditorPrefs.SetInt(this.m_Prefix + "ViewMode", (int) this.m_ItemViewMode);
     EditorPrefs.SetFloat(this.m_Prefix + "ItemHeight", this.m_PreviewHeight);
     EditorPrefs.SetFloat(this.m_Prefix + "Scroll", this.m_ScrollPosition.y);
     EditorPrefs.SetString(this.m_Prefix + "CurrentLib", this.m_CurrrentLibrary);
   }
 }
 public void TransferEditorPrefsState(bool load)
 {
     if (load)
     {
         this.m_ItemViewMode     = (PresetLibraryEditorState.ItemViewMode)EditorPrefs.GetInt(this.m_Prefix + "ViewMode", (int)this.m_ItemViewMode);
         this.m_PreviewHeight    = EditorPrefs.GetFloat(this.m_Prefix + "ItemHeight", this.m_PreviewHeight);
         this.m_ScrollPosition.y = EditorPrefs.GetFloat(this.m_Prefix + "Scroll", this.m_ScrollPosition.y);
         this.m_CurrrentLibrary  = EditorPrefs.GetString(this.m_Prefix + "CurrentLib", this.m_CurrrentLibrary);
     }
     else
     {
         EditorPrefs.SetInt(this.m_Prefix + "ViewMode", (int)this.m_ItemViewMode);
         EditorPrefs.SetFloat(this.m_Prefix + "ItemHeight", this.m_PreviewHeight);
         EditorPrefs.SetFloat(this.m_Prefix + "Scroll", this.m_ScrollPosition.y);
         EditorPrefs.SetString(this.m_Prefix + "CurrentLib", this.m_CurrrentLibrary);
     }
 }
예제 #9
0
        private void ListArea(Rect rect, PresetLibrary lib, object newPresetObject)
        {
            if (lib != null)
            {
                int   num2;
                int   num3;
                Event current = Event.current;
                if ((this.m_PresetLibraryFileLocation == PresetFileLocation.ProjectFolder) && (current.type == EventType.Repaint))
                {
                    this.m_IsOpenForEdit = AssetDatabase.IsOpenForEdit(this.pathWithExtension);
                }
                else if (this.m_PresetLibraryFileLocation == PresetFileLocation.PreferencesFolder)
                {
                    this.m_IsOpenForEdit = true;
                }
                if (!this.m_IsOpenForEdit)
                {
                    Rect rect2 = new Rect(rect.x, rect.yMax - this.versionControlAreaHeight, rect.width, this.versionControlAreaHeight);
                    this.VersionControlArea(rect2);
                    rect.height -= this.versionControlAreaHeight;
                }
                for (int i = 0; i < 2; i++)
                {
                    this.gridWidth = !this.m_ShowedScrollBarLastFrame ? rect.width : (rect.width - 17f);
                    this.SetupGrid(this.gridWidth, lib.Count());
                    bool flag = this.m_Grid.height > rect.height;
                    if (flag == this.m_ShowedScrollBarLastFrame)
                    {
                        break;
                    }
                    this.m_ShowedScrollBarLastFrame = flag;
                }
                if ((this.m_ShowedScrollBarLastFrame || this.alwaysShowScrollAreaHorizontalLines) && (Event.current.type == EventType.Repaint))
                {
                    Rect rect3 = new RectOffset(1, 1, 1, 1).Add(rect);
                    rect3.height = 1f;
                    EditorGUI.DrawRect(rect3, new Color(0f, 0f, 0f, 0.3f));
                    rect3.y += rect.height + 1f;
                    EditorGUI.DrawRect(rect3, new Color(0f, 0f, 0f, 0.3f));
                }
                Rect viewRect = new Rect(0f, 0f, 1f, this.m_Grid.height);
                this.m_State.m_ScrollPosition = GUI.BeginScrollView(rect, this.m_State.m_ScrollPosition, viewRect);
                float gridStartY = 0f;
                int   maxIndex   = !this.m_ShowAddNewPresetItem ? (lib.Count() - 1) : lib.Count();
                bool  flag2      = this.m_Grid.IsVisibleInScrollView(rect.height, this.m_State.m_ScrollPosition.y, gridStartY, maxIndex, out num2, out num3);
                bool  flag3      = false;
                if (flag2)
                {
                    if (this.GetRenameOverlay().IsRenaming() && !this.GetRenameOverlay().isWaitingForDelay)
                    {
                        if (!this.m_State.m_RenameOverlay.OnGUI())
                        {
                            this.EndRename();
                            current.Use();
                        }
                        this.Repaint();
                    }
                    for (int j = num2; j <= num3; j++)
                    {
                        bool flag4;
                        Rect dragRect;
                        int  controlID  = j + 0xf4240;
                        Rect itemRect   = this.m_Grid.CalcRect(j, gridStartY);
                        Rect buttonRect = itemRect;
                        Rect position   = itemRect;
                        PresetLibraryEditorState.ItemViewMode itemViewMode = this.m_State.itemViewMode;
                        if ((itemViewMode != PresetLibraryEditorState.ItemViewMode.Grid) && (itemViewMode == PresetLibraryEditorState.ItemViewMode.List))
                        {
                            buttonRect.width = this.m_State.m_PreviewHeight * this.m_PreviewAspect;
                            position.x      += buttonRect.width + 8f;
                            position.width  -= buttonRect.width + 10f;
                            position.height  = 16f;
                            position.y       = itemRect.yMin + ((itemRect.height - 16f) * 0.5f);
                        }
                        if (this.m_ShowAddNewPresetItem && (j == lib.Count()))
                        {
                            this.CreateNewPresetButton(buttonRect, newPresetObject, lib, this.m_IsOpenForEdit);
                        }
                        else
                        {
                            flag4 = this.IsRenaming(j);
                            if (flag4)
                            {
                                Rect rect8 = position;
                                rect8.y--;
                                rect8.x--;
                                this.m_State.m_RenameOverlay.editFieldRect = rect8;
                            }
                            switch (current.type)
                            {
                            case EventType.MouseDown:
                                if ((current.button == 0) && itemRect.Contains(current.mousePosition))
                                {
                                    GUIUtility.hotControl = controlID;
                                    if (current.clickCount == 1)
                                    {
                                        this.m_ItemClickedCallback(current.clickCount, lib.GetPreset(j));
                                        current.Use();
                                    }
                                }
                                break;

                            case EventType.MouseUp:
                                if (GUIUtility.hotControl == controlID)
                                {
                                    GUIUtility.hotControl = 0;
                                    if (((current.button == 0) && itemRect.Contains(current.mousePosition)) && (Event.current.alt && this.m_IsOpenForEdit))
                                    {
                                        this.DeletePreset(j);
                                        current.Use();
                                    }
                                }
                                break;

                            case EventType.MouseMove:
                                if (!itemRect.Contains(current.mousePosition))
                                {
                                    goto Label_0812;
                                }
                                if (this.m_State.m_HoverIndex != j)
                                {
                                    this.m_State.m_HoverIndex = j;
                                    this.Repaint();
                                }
                                break;

                            case EventType.MouseDrag:
                                if ((GUIUtility.hotControl == controlID) && this.m_IsOpenForEdit)
                                {
                                    DragAndDropDelay stateObject = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), controlID);
                                    if (stateObject.CanStartDrag())
                                    {
                                        DragAndDrop.PrepareStartDrag();
                                        DragAndDrop.SetGenericData("DraggingPreset", j);
                                        DragAndDrop.objectReferences = new UnityEngine.Object[0];
                                        DragAndDrop.StartDrag(string.Empty);
                                        this.m_DragState.draggingIndex = j;
                                        this.m_DragState.dragUponIndex = j;
                                        GUIUtility.hotControl          = 0;
                                    }
                                    current.Use();
                                }
                                break;

                            case EventType.Repaint:
                                if ((this.m_State.m_HoverIndex == j) && !itemRect.Contains(current.mousePosition))
                                {
                                    goto Label_046D;
                                }
                                goto Label_0479;

                            case EventType.DragUpdated:
                            case EventType.DragPerform:
                                dragRect = this.GetDragRect(itemRect);
                                if (!dragRect.Contains(current.mousePosition))
                                {
                                    break;
                                }
                                this.m_DragState.dragUponIndex = j;
                                this.m_DragState.dragUponRect  = itemRect;
                                if (this.m_State.itemViewMode != PresetLibraryEditorState.ItemViewMode.List)
                                {
                                    goto Label_0694;
                                }
                                this.m_DragState.insertAfterIndex = ((current.mousePosition.y - dragRect.y) / dragRect.height) > 0.5f;
                                goto Label_06C5;

                            case EventType.DragExited:
                                if (this.m_DragState.IsDragging())
                                {
                                    this.ClearDragState();
                                    current.Use();
                                }
                                break;

                            case EventType.ContextClick:
                                if (itemRect.Contains(current.mousePosition))
                                {
                                    PresetContextMenu <T> .Show(this.m_IsOpenForEdit, j, newPresetObject, (PresetLibraryEditor <T>) this);

                                    current.Use();
                                }
                                break;
                            }
                        }
                        continue;
Label_046D:
                        this.m_State.m_HoverIndex = -1;
Label_0479:
                        if ((this.m_DragState.draggingIndex == j) || (GUIUtility.hotControl == controlID))
                        {
                            this.DrawHoverEffect(itemRect, false);
                        }
                        lib.Draw(buttonRect, j);
                        if (!flag4 && this.drawLabels)
                        {
                            GUI.Label(position, GUIContent.Temp(lib.GetName(j)));
                        }
                        if ((this.m_DragState.dragUponIndex == j) && (this.m_DragState.draggingIndex != this.m_DragState.dragUponIndex))
                        {
                            flag3 = true;
                        }
                        if (((GUIUtility.hotControl == 0) && Event.current.alt) && this.m_IsOpenForEdit)
                        {
                            EditorGUIUtility.AddCursorRect(itemRect, MouseCursor.ArrowMinus);
                        }
                        continue;
Label_0694:
                        this.m_DragState.insertAfterIndex = ((current.mousePosition.x - dragRect.x) / dragRect.width) > 0.5f;
Label_06C5:
                        if (current.type == EventType.DragPerform)
                        {
                            if (this.m_DragState.draggingIndex >= 0)
                            {
                                this.MovePreset(this.m_DragState.draggingIndex, this.m_DragState.dragUponIndex, this.m_DragState.insertAfterIndex);
                                DragAndDrop.AcceptDrag();
                            }
                            this.ClearDragState();
                        }
                        DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                        current.Use();
                        continue;
Label_0812:
                        if (this.m_State.m_HoverIndex == j)
                        {
                            this.m_State.m_HoverIndex = -1;
                            this.Repaint();
                        }
                    }
                    if (flag3)
                    {
                        this.DrawDragInsertionMarker();
                    }
                }
                GUI.EndScrollView();
            }
        }
예제 #10
0
        private void ListArea(Rect rect, PresetLibrary lib, object newPresetObject)
        {
            if (lib == null)
            {
                return;
            }
            Event current = Event.current;

            if (this.m_PresetLibraryFileLocation == PresetFileLocation.ProjectFolder && current.type == EventType.Repaint)
            {
                this.m_IsOpenForEdit = AssetDatabase.IsOpenForEdit(this.pathWithExtension);
            }
            else
            {
                if (this.m_PresetLibraryFileLocation == PresetFileLocation.PreferencesFolder)
                {
                    this.m_IsOpenForEdit = true;
                }
            }
            if (!this.m_IsOpenForEdit)
            {
                Rect rect2 = new Rect(rect.x, rect.yMax - this.versionControlAreaHeight, rect.width, this.versionControlAreaHeight);
                this.VersionControlArea(rect2);
                rect.height -= this.versionControlAreaHeight;
            }
            for (int i = 0; i < 2; i++)
            {
                this.gridWidth = ((!this.m_ShowedScrollBarLastFrame) ? rect.width : (rect.width - 17f));
                this.SetupGrid(this.gridWidth, lib.Count());
                bool flag = this.m_Grid.height > rect.height;
                if (flag == this.m_ShowedScrollBarLastFrame)
                {
                    break;
                }
                this.m_ShowedScrollBarLastFrame = flag;
            }
            if ((this.m_ShowedScrollBarLastFrame || this.alwaysShowScrollAreaHorizontalLines) && Event.current.type == EventType.Repaint)
            {
                Rect rect3 = new RectOffset(1, 1, 1, 1).Add(rect);
                rect3.height = 1f;
                EditorGUI.DrawRect(rect3, new Color(0f, 0f, 0f, 0.3f));
                rect3.y += rect.height + 1f;
                EditorGUI.DrawRect(rect3, new Color(0f, 0f, 0f, 0.3f));
            }
            Rect viewRect = new Rect(0f, 0f, 1f, this.m_Grid.height);

            this.m_State.m_ScrollPosition = GUI.BeginScrollView(rect, this.m_State.m_ScrollPosition, viewRect);
            float num      = 0f;
            int   maxIndex = (!this.m_ShowAddNewPresetItem) ? (lib.Count() - 1) : lib.Count();
            int   num2;
            int   num3;
            bool  flag2 = this.m_Grid.IsVisibleInScrollView(rect.height, this.m_State.m_ScrollPosition.y, num, maxIndex, out num2, out num3);
            bool  flag3 = false;

            if (flag2)
            {
                if (this.GetRenameOverlay().IsRenaming() && !this.GetRenameOverlay().isWaitingForDelay)
                {
                    if (!this.m_State.m_RenameOverlay.OnGUI())
                    {
                        this.EndRename();
                        current.Use();
                    }
                    this.Repaint();
                }
                for (int j = num2; j <= num3; j++)
                {
                    int  num4  = j + 1000000;
                    Rect rect4 = this.m_Grid.CalcRect(j, num);
                    Rect rect5 = rect4;
                    Rect rect6 = rect4;
                    PresetLibraryEditorState.ItemViewMode itemViewMode = this.m_State.itemViewMode;
                    if (itemViewMode != PresetLibraryEditorState.ItemViewMode.Grid)
                    {
                        if (itemViewMode == PresetLibraryEditorState.ItemViewMode.List)
                        {
                            rect5.width  = this.m_State.m_PreviewHeight * this.m_PreviewAspect;
                            rect6.x     += rect5.width + 8f;
                            rect6.width -= rect5.width + 10f;
                            rect6.height = 16f;
                            rect6.y      = rect4.yMin + (rect4.height - 16f) * 0.5f;
                        }
                    }
                    if (this.m_ShowAddNewPresetItem && j == lib.Count())
                    {
                        this.CreateNewPresetButton(rect5, newPresetObject, lib, this.m_IsOpenForEdit);
                    }
                    else
                    {
                        bool flag4 = this.IsRenaming(j);
                        if (flag4)
                        {
                            Rect editFieldRect = rect6;
                            editFieldRect.y -= 1f;
                            editFieldRect.x -= 1f;
                            this.m_State.m_RenameOverlay.editFieldRect = editFieldRect;
                        }
                        switch (current.type)
                        {
                        case EventType.MouseDown:
                            if (current.button == 0 && rect4.Contains(current.mousePosition))
                            {
                                GUIUtility.hotControl = num4;
                                if (current.clickCount == 1)
                                {
                                    this.m_ItemClickedCallback(current.clickCount, lib.GetPreset(j));
                                    current.Use();
                                }
                            }
                            break;

                        case EventType.MouseUp:
                            if (GUIUtility.hotControl == num4)
                            {
                                GUIUtility.hotControl = 0;
                                if (current.button == 0 && rect4.Contains(current.mousePosition) && Event.current.alt && this.m_IsOpenForEdit)
                                {
                                    this.DeletePreset(j);
                                    current.Use();
                                }
                            }
                            break;

                        case EventType.MouseMove:
                            if (rect4.Contains(current.mousePosition))
                            {
                                if (this.m_State.m_HoverIndex != j)
                                {
                                    this.m_State.m_HoverIndex = j;
                                    this.Repaint();
                                }
                            }
                            else
                            {
                                if (this.m_State.m_HoverIndex == j)
                                {
                                    this.m_State.m_HoverIndex = -1;
                                    this.Repaint();
                                }
                            }
                            break;

                        case EventType.MouseDrag:
                            if (GUIUtility.hotControl == num4 && this.m_IsOpenForEdit)
                            {
                                DragAndDropDelay dragAndDropDelay = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), num4);
                                if (dragAndDropDelay.CanStartDrag())
                                {
                                    DragAndDrop.PrepareStartDrag();
                                    DragAndDrop.SetGenericData("DraggingPreset", j);
                                    DragAndDrop.objectReferences = new UnityEngine.Object[0];
                                    DragAndDrop.StartDrag(string.Empty);
                                    this.m_DragState.draggingIndex = j;
                                    this.m_DragState.dragUponIndex = j;
                                    GUIUtility.hotControl          = 0;
                                }
                                current.Use();
                            }
                            break;

                        case EventType.Repaint:
                            if (this.m_State.m_HoverIndex == j)
                            {
                                if (!rect4.Contains(current.mousePosition))
                                {
                                    this.m_State.m_HoverIndex = -1;
                                }
                            }
                            if (this.m_DragState.draggingIndex == j || GUIUtility.hotControl == num4)
                            {
                                this.DrawHoverEffect(rect4, false);
                            }
                            lib.Draw(rect5, j);
                            if (!flag4 && this.drawLabels)
                            {
                                GUI.Label(rect6, GUIContent.Temp(lib.GetName(j)));
                            }
                            if (this.m_DragState.dragUponIndex == j && this.m_DragState.draggingIndex != this.m_DragState.dragUponIndex)
                            {
                                flag3 = true;
                            }
                            if (GUIUtility.hotControl == 0 && Event.current.alt && this.m_IsOpenForEdit)
                            {
                                EditorGUIUtility.AddCursorRect(rect4, MouseCursor.ArrowMinus);
                            }
                            break;

                        case EventType.DragUpdated:
                        case EventType.DragPerform:
                        {
                            Rect dragRect = this.GetDragRect(rect4);
                            if (dragRect.Contains(current.mousePosition))
                            {
                                this.m_DragState.dragUponIndex = j;
                                this.m_DragState.dragUponRect  = rect4;
                                if (this.m_State.itemViewMode == PresetLibraryEditorState.ItemViewMode.List)
                                {
                                    this.m_DragState.insertAfterIndex = ((current.mousePosition.y - dragRect.y) / dragRect.height > 0.5f);
                                }
                                else
                                {
                                    this.m_DragState.insertAfterIndex = ((current.mousePosition.x - dragRect.x) / dragRect.width > 0.5f);
                                }
                                bool flag5 = current.type == EventType.DragPerform;
                                if (flag5)
                                {
                                    if (this.m_DragState.draggingIndex >= 0)
                                    {
                                        this.MovePreset(this.m_DragState.draggingIndex, this.m_DragState.dragUponIndex, this.m_DragState.insertAfterIndex);
                                        DragAndDrop.AcceptDrag();
                                    }
                                    this.ClearDragState();
                                }
                                DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                                current.Use();
                            }
                            break;
                        }

                        case EventType.DragExited:
                            if (this.m_DragState.IsDragging())
                            {
                                this.ClearDragState();
                                current.Use();
                            }
                            break;

                        case EventType.ContextClick:
                            if (rect4.Contains(current.mousePosition))
                            {
                                PresetLibraryEditor <T> .PresetContextMenu.Show(this.m_IsOpenForEdit, j, newPresetObject, this);

                                current.Use();
                            }
                            break;
                        }
                    }
                }
                if (flag3)
                {
                    this.DrawDragInsertionMarker();
                }
            }
            GUI.EndScrollView();
        }