Ejemplo n.º 1
0
        private static void LoadResources()
        {
            if (list == null)
            {
                list = ListData.LoadList();
            }

            if (DEFAULT_ICON == null)
            {
                BORDER_SPACE = ICON_SPACE.x - ICON_SIZE * 2 - 25; // 25 because of scrollbar
                DEFAULT_ICON = EditorGUIUtility.IconContent("cs Script Icon").image;
                CLOSE_ICON   = EditorGUIUtility.FindTexture("winbtn_mac_close_a");
                ICON_SPACE   = GUIStyle.none.CalcSize(new GUIContent(DEFAULT_ICON));

#if UNITY_5_4_OR_NEWER
                WINDOW_ICON = Base64.FromBase64(Constants.WINDOW_ICON);
#endif
            }
        }
Ejemplo n.º 2
0
        private void OnGUI()
        {
            LoadResources();

            if (pathList.Count <= 0)
            {
                if (GUILayout.Button(new GUIContent("Create a Favorites List"), GUILayout.MinHeight(50f)))
                {
                    EditorApplication.ExecuteMenuItem("Assets/Create/" + Constants.CREATE_MENU_OPTION);
                }
                return;
            }

            GUILayout.BeginHorizontal(SKIN_TOOLBAR);
            index = EditorGUILayout.Popup(index, listNames.ToArray(), EditorStyles.toolbarDropDown);

            selectedName = listNames[index];
            list         = ListData.LoadList(pathList[index]);

            if (GUILayout.Button(EditorGUIUtility.FindTexture(BUTTON_ICON_SELECT), SKIN_BUTTON, GUILayout.MaxWidth(ICON_BUTTON_WIDTH)))
            {
                EditorGUIUtility.PingObject(list);
            }
            if (GUILayout.Button(EditorGUIUtility.FindTexture(BUTTON_ICON_ADD), SKIN_BUTTON, GUILayout.MaxWidth(ICON_BUTTON_WIDTH)))
            {
                EditorApplication.ExecuteMenuItem("Assets/Create/" + Constants.CREATE_MENU_OPTION);
            }
            GUILayout.EndHorizontal();

            searchText = SearchUtils.BeginSearchbar(this, searchText);
            if (SearchUtils.Button(new GUIContent("Remove All"), GUILayout.MaxWidth(CLEAR_BUTTON_WIDTH)))
            {
                list.Clear();

                Repaint();
            }
            SearchUtils.EndSearchbar();


            using (var scrollView = new GUILayout.ScrollViewScope(scrollPos, false, false))
            {
                scrollPos = scrollView.scrollPosition;

                for (int i = list.References.Count - 1; i >= 0; i--)
                {
                    var reference = list.References[i];

                    if (SearchUtils.IsSearched(reference, searchText))
                    {
                        if (DrawElement(reference))
                        {
                            list.RemoveReference(reference);
                        }
                    }
                }

                list.References.RemoveAll(reference => reference == null);
            }

            DetectDragNDrop();
        }