Beispiel #1
0
        public static string ReferencePopup(string _title, string _hint, string _key, List <string> _list, string _help = "")
        {
            if (_list == null || _list.Count == 0)
            {
                EditorGUILayout.LabelField(_title + " - " + _key + " (EMPTY LIST)");
                return(_key);
            }
            else
            {
                _list.Insert(0, " ");

                string[] _names = new string[_list.Count];

                int _index = 0;
                for (int i = 0; i < _list.Count; i++)
                {
                    if (_list[i] == " " && i == 0)
                    {
                        _names[i] = " ";
                    }
                    else if (_list[i] == " ")
                    {
                        _names[i] = "";
                    }
                    else
                    {
                        _names[i] = _list[i];
                    }

                    if (_key == _names[i])
                    {
                        _index = i;
                    }
                }

                Color _org_color = GUI.backgroundColor;
                if (!string.IsNullOrEmpty(_key) && _index == 0)
                {
                    _names = SystemTools.AddArrayValue(_names, _key, ref _index);
                    GUI.backgroundColor = Color.red;
                }

                if (_title.Trim() != "")
                {
                    _index = ICEEditorLayout.Popup(_title, _hint, _index, _names, _help);
                }
                else
                {
                    _index = EditorGUILayout.Popup(_index, _names);
                }

                GUI.backgroundColor = _org_color;

                return(_names[_index].Trim());
            }
        }