public ChooseEntetyFromListHelper InitWindow <T>() where T : DataObject
        {
            ItemEditorViewer = BaseEditorStatic.GetDataViewer <T>();
            FilterViewer     = BaseEditorStatic.GetDataFilter <T>();
            var listItems = BaseEditorStatic.DataStorager.All <T>().ToList();

            FilterViewer.InitData(new ArrayList(listItems));
            _dicItems = new Dictionary <string, DataObject>();
            listItems.ForEach(i => _dicItems.Add(string.Format("{0}-{1}", i.Id, i.Name), i));
            _btnNames = _dicItems.Keys.ToArray();

            if (ItemEditorViewer.CanShow)
            {
                for (var i = 0; i < _btnNames.Length; i++)
                {
                    if (_btnNames[i] == string.Format("{0}-{1}", ItemEditorViewer.GetCurrent().Id, ItemEditorViewer.CurrentName))
                    {
                        _currentIndex = i;
                        break;
                    }
                }
            }
            else
            {
                _currentIndex = 0;
                ItemEditorViewer.SetCurrent(_dicItems[_btnNames[_currentIndex]]);
            }
            return(this);
        }
Ejemplo n.º 2
0
        private void Awake()
        {
            _viewerEntity = BaseEditorStatic.GetDataViewer(CurrentBox.ObjectType);
            _viewerEntity.RefreshWindow += this.Repaint;
            _filterViewer = BaseEditorStatic.GetDataFilter(CurrentBox.ObjectType);
            _filterViewer.ChooseItemShow += item => _viewerEntity.SetCurrent(item);
            _filterViewer.RefreshWindow  += this.Repaint;

            ReloadData();
        }
 protected void DrawAllElements(Rect rect)
 {
     GUILayout.BeginArea(rect);
     {
         _scrollPosAllElemntsWindow = GUILayout.BeginScrollView(_scrollPosAllElemntsWindow, false, false, GUILayout.ExpandHeight(true), GUILayout.Height(rect.height - 2));
         EditorGUI.BeginChangeCheck();
         _currentIndex = GUILayout.SelectionGrid(_currentIndex, _btnNames, 1);
         if (EditorGUI.EndChangeCheck())
         {
             ItemEditorViewer.SetCurrent(_dicItems[_btnNames[_currentIndex]]);
             //  FilterViewer.SetCurrent(_dicItems[_btnNames[_currentIndex]]);
         }
         GUILayout.EndScrollView();
     }
     GUILayout.EndArea();
 }