public IScriptableListItem DrawSellectableList <T>(List <T> list, T selectedItem, int width) where T : IScriptableListItem
        {
            GUILayout.BeginVertical();
            List <int>          searchResult = searchBar.DrawSearchBar <T>(list, width - 100);
            IScriptableListItem sellected    = base.DrawSellectableList <T>(list, selectedItem, searchResult, width);

            GUILayout.EndVertical();
            return(sellected);
        }
Exemple #2
0
        public void OnGUI()
        {
            IScriptableListItem newSelectedItem = drawList(selectedItem as IScriptableListItem);

            if (newSelectedItem != selectedItem && newSelectedItem != null)
            {
                selectedItems[windowId] = newSelectedItem;
                Close();
            }
        }
Exemple #3
0
 private void Draw(IScriptableListItem Element, int width)
 {
     if (newSelectedItem == Element as IScriptableListItem)
     {
         GUI.backgroundColor = Color.cyan;
     }
     if (GUILayout.Button((Element as IScriptableListItem).ContentForListMaximal(), GUILayout.Width(width - 30), GUILayout.Height(40), GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false)))
     {
         newSelectedItem = Element;
     }
     GUI.backgroundColor = Color.white;
 }
Exemple #4
0
        public virtual IScriptableListItem DrawSellectableList <T>(List <T> list, T selectedItem, List <int> searchResult, int width = 130) where T : IScriptableListItem
        {
            GUILayout.BeginVertical();
            itemInRaw = Mathf.Clamp(width / 150, 1, int.MaxValue);
            if (list == null)
            {
                newSelectedItem = null;
            }
            newSelectedItem = selectedItem;

            scrollPos = GUILayout.BeginScrollView(scrollPos, false, true, GUILayout.Width(width));

            int selected = -1;
            List <GUIContent> content = new List <GUIContent>();

            for (int i = 0; i < list.Count; i++)
            {
                if (searchResult.Count == 0 || searchResult.Contains(i))
                {
                    content.Add(list[i].ContentForListMaximal());
                    if (selectedItem != null && list[i].ConfigId == selectedItem.ConfigId)
                    {
                        selected = content.Count - 1;
                    }
                }
            }

            selected = GUILayout.SelectionGrid(selected, content.ToArray(), Mathf.RoundToInt(itemInRaw), GUILayout.MaxWidth(150 * itemInRaw));
            GUILayout.EndScrollView();
            GUILayout.EndVertical();

            if (selected < list.Count && selected >= 0)
            {
                if (searchResult.Count == 0 || list.Count == searchResult.Count)
                {
                    newSelectedItem = list[selected];
                }
                else
                {
                    newSelectedItem = list[searchResult[selected]];
                }
            }
            else
            {
            }

            return((T)newSelectedItem);
        }
Exemple #5
0
        public static ScriptableListWindow ShowWindow <T>(string id, IScriptableListItem selected) where T : BaseScriptableDrowableItem
        {
            windowId = id;

            EditorWindow window = EditorWindow.GetWindow(typeof(ScriptableListWindow));

            if (selectedItems.ContainsKey(windowId))
            {
                selectedItems.Remove(windowId);
            }

            selectedItems.Add(windowId, selected);
            selectedItem = selected;
            (window as ScriptableListWindow).drawList = (IScriptableListItem sellected) =>
            {
                return((window as ScriptableListWindow).listWiew.DrawSellectableList <T>(ScriptableList <T> .instance.list, selectedItem as T,
                                                                                         Mathf.RoundToInt((window as ScriptableListWindow).position.width)));
            };
            return(window as ScriptableListWindow);
        }