protected void DrawBtnsElements(Rect rect)
        {
            GUILayout.BeginArea(rect);
            {
                EditorGUILayout.BeginHorizontal();
                if (ItemEditorViewer.CanShow)
                {
                    GUIContent content = new GUIContent()
                    {
                        image   = _iconSelect,
                        text    = string.Format("Choose Current id"),
                        tooltip = string.Format("Choose Current")
                    };

                    if (GUILayout.Button(content, GUILayout.Width(170), GUILayout.Height(30)))
                    {
                        if (ChooseDataObjectEvent != null)
                        {
                            ChooseDataObjectEvent.Invoke(ItemEditorViewer.GetCurrent());
                        }
                        Close();
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            GUILayout.EndArea();
        }
        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);
        }
Example #3
0
        private void AddRemoveChoose()
        {
            if (GUILayout.Button("Add"))
            {
                CurrentBox.CreateNew();

                SaveCurrentAsset();
                CurrentBox.OnBeforeSerialize();
                _filterViewer.SetLast();
            }

            if (GUILayout.Button("Del "))
            {
                CurrentBox.Remove(_viewerEntity.GetCurrent().Id);
                CurrentBox.OnBeforeSerialize();
                SaveCurrentAsset();
            }
            _filterViewer.DrawSearch();

            if (GUILayout.Button("Ser "))
            {
                CurrentBox.OnBeforeSerialize();
                CurrentBox.SaveToFile();
            }

            if (GUILayout.Button("DESer "))
            {
                CurrentBox.LoadFromFile();
                CurrentBox.Reload();
                this.Repaint();
            }
        }