Ejemplo n.º 1
0
        public SelectionBoxItems <T> Draw <T>(List <SelectionBoxItems <T> > values, SelectionBoxItems <T> value)
        {
            items = new List <BaseSelectionBoxItem>();

            for (int i = 0; i < values.Count; i++)
            {
                items.Add(values[i]);
            }

            item = value;

            return(item as SelectionBoxItems <T>);
        }
Ejemplo n.º 2
0
        void OnGUI()
        {
            if (items == null)
            {
                Close();
                return;
            }

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, "Box");
            GUILayout.BeginVertical();

            searchBox = EditorGUILayout.TextField("", searchBox, GUI.skin.FindStyle("ToolbarSeachTextField"));

            GUILayout.Space(5);

            BaseSelectionBoxItem currentItem;

            for (int i = 0; i < items.Count; i++)
            {
                currentItem = items[i];

                if (searchBox == "" || currentItem.itemName == "None" || currentItem.itemName.ToLower().Contains(searchBox.ToLower()))
                {
                    GUI.backgroundColor = item == currentItem ? Color.gray : Color.white;
                    if (GUILayout.Button(currentItem.itemName, EditorStyles.objectFieldThumb))
                    {
                        if (clickDone)
                        {
                            Close();
                        }

                        lastTime = System.DateTime.Now;
                        item     = currentItem;
                    }
                    GUI.backgroundColor = Color.white;
                }
            }

            GUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
        }