public static bool ShrunkListIfNeeded()
        {
            bool hasChanged = false;

            if (SelectedObjectsCount >= UnityEssentialsPreferences.GetMaxSelectedObjectStored())
            {
                hasChanged = true;
                SelectedObjectsList.RemoveAt(0);
            }
            while (SelectedObjectsWithoutDuplicateCount >= UnityEssentialsPreferences.GetMaxObjectSHown())
            {
                hasChanged = true;
                SelectedObjectsWithoutDuplicateList.RemoveAt(0);
            }
            while (PinnedObjectsCount >= UnityEssentialsPreferences.GetMaxPinnedObject())
            {
                hasChanged = true;
                PinnedObjectsList.RemoveAt(0);
            }
            while (PinnedObjectsInScenesCount >= UnityEssentialsPreferences.GetMaxPinnedObject())
            {
                hasChanged = true;
                PinnedObjectsInScenesList.RemoveAt(0);
                PinnedObjectsNameInScenesList.RemoveAt(0);
                PinnedObjectsScenesLinkList.RemoveAt(0);
            }
            return(hasChanged);
        }
Exemplo n.º 2
0
        private void DisplayOneItem(Object toDisplay, string nameInListPath, int index, float width, bool disable)
        {
            if (toDisplay == null && string.IsNullOrEmpty(nameInListPath))
            {
                return;
            }

            if (toDisplay == null && !UnityEssentialsPreferences.GetBool(UnityEssentialsPreferences.SHOW_GAMEOBJECTS_FROM_OTHER_SCENE, true))
            {
                return;
            }

            GUI.color = (PeekSerializeObject.LastSelectedObject == toDisplay && toDisplay != null) ? Color.green : Color.white;

            EditorGUI.BeginDisabledGroup(disable);
            {
                using (HorizontalScope horizontalScope = new HorizontalScope(GUILayout.Width(width), GUILayout.Height(_heightLine)))
                {
                    float widthExtent = CalculateWidthExtentOptions.CalculateWidthExtent(width, index, ListToDisplay.arraySize);
                    float widthButtonWithoutExtent = CalculateWidthExtentOptions.CalculateButtonWidthWithoutExtent(widthExtent, _heightLine, _margin);

                    if (_calculateExtent)
                    {
                        GUILayout.Label("", GUILayout.Width(widthExtent), GUILayout.Height(_heightLine));
                    }
                    //display bookmark button
                    bool clicOnBookMark = BookMarkButtonOptions.ButtonImageWithHover(WIDTH_BUTTON_HOVER, toDisplay != null, _heightLine);
                    if (clicOnBookMark)
                    {
                        OnBookMarkClic?.Invoke(index);
                        return;
                    }
                    //display main logo
                    DisplayLogoByTypeOfObject(toDisplay, _heightLine);
                    if (!disable && !_dragSettings.IsDragging)
                    {
                        Rect logoContent = GUILayoutUtility.GetLastRect();
                        if (logoContent.Contains(Event.current.mousePosition))
                        {
                            EditorGUIUtility.AddCursorRect(logoContent, MouseCursor.MoveArrow);
                            if (Event.current.type == EventType.MouseDown)
                            {
                                _listToDisplayCopy = ListToDisplay.ToObjectList();
                                _dragSettings.StartDragging(index, logoContent);
                                Event.current.Use();
                            }
                        }
                    }
                    //display main button
                    EditorGUI.BeginDisabledGroup(toDisplay == null);
                    {
                        string nameObjectToSelect;
                        if (toDisplay == null)
                        {
                            nameObjectToSelect = !string.IsNullOrEmpty(nameInListPath) ? ObjectNames.NicifyVariableName(nameInListPath) : " --- not found --- ";
                        }
                        else
                        {
                            nameObjectToSelect = ObjectNames.NicifyVariableName(toDisplay.name);
                        }


                        GUIContent buttonSelectContent = ShortenNameIfNeeded(nameObjectToSelect, width, widthButtonWithoutExtent);
                        buttonSelectContent.tooltip = "Clic to select, Right clic to Pin only";
                        if (GUILayout.Button(buttonSelectContent, BookMarkButtonOptions.GuiStyle, GUILayout.ExpandWidth(true), GUILayout.Height(_heightLine)))
                        {
                            if (Event.current.button == 0)
                            {
                                OnSelectItem?.Invoke(index);
                            }
                            else
                            {
                                OnPinItem?.Invoke(index);
                            }
                            return;
                        }
                    }
                    EditorGUI.EndDisabledGroup();

                    //display special scene buttons
                    if (toDisplay == null && OnInfoItem != null)
                    {
                        bool selectScene = false;
                        bool goToScene   = false;

                        DisplaySpecialSceneSettings(ref selectScene, ref goToScene);
                        if (goToScene)
                        {
                            OnInfoForceItem?.Invoke(index);
                            return;
                        }
                        else if (selectScene)
                        {
                            OnInfoItem?.Invoke(index);
                            return;
                        }
                    }

                    //display delete button
                    GUIContent buttonDeletContent = EditorGUIUtility.IconContent(DELETE_ICON);
                    buttonDeletContent.tooltip = "Remove from list";
                    if (GUILayout.Button(buttonDeletContent, BookMarkButtonOptions.GuiStyle, GUILayout.ExpandWidth(false), GUILayout.MaxWidth(WIDTH_BUTTON_HOVER), GUILayout.Height(_heightLine)) &&
                        Event.current.button == 0)
                    {
                        OnRemoveItem?.Invoke(index);
                        return;
                    }
                    if (_calculateExtent)
                    {
                        GUILayout.Label("", GUILayout.Width(widthExtent), GUILayout.Height(_heightLine));
                    }
                }
            }
            EditorGUI.EndDisabledGroup();
        }