protected override void DrawEdit(ref Rect pos)
    {
        base.DrawEdit(ref pos);
        pos.height = SingleLineHeight;

        if (CheckIfComponentInitialized(ref pos))
        {
            return;
        }


        var availableCollections = AvailableCollections;

        if (availableCollections.Count == 0)
        {
            EditorGUI.LabelField(pos, "no collection found to choose from.");
            _selectedCollection = null;
        }

        else
        {
            int selectedCollectionIndex = availableCollections.IndexOf(_selectedCollection);
            if (selectedCollectionIndex == -1)
            {
                _selectedCollection = null;
            }

            var newSelectedCollectionIndex = EditorGUI.Popup(pos, "Select Collection", selectedCollectionIndex, availableCollections.Select(x => x.FieldName).ToArray());
            if (newSelectedCollectionIndex != -1 && newSelectedCollectionIndex != selectedCollectionIndex)
            {
                _selectedCollection = availableCollections[newSelectedCollectionIndex];
            }
        }
    }
Esempio n. 2
0
 public CollectionComponent_CountLimiter(EntryComponent_Collection collection)
 {
     if (collection == null)
     {
         throw new ArgumentNullException("collection");
     }
     this._collection = collection;
 }
    private void CheckIfCollectionRemoved(List <EntryComponent_Collection> collectionsList)
    {
        int selectedCollectionIndex = collectionsList.IndexOf(_selectedCollection);

        if (selectedCollectionIndex == -1)
        {
            _selectedCollection = null;
        }
    }
Esempio n. 4
0
 public CollectionComponent_CountLimiter(EntryComponent_Collection collection, CollectionComponent_CountLimiter other)
 {
     if (collection == null)
     {
         throw new ArgumentNullException("collection");
     }
     _collection       = collection;
     _minCount         = other._minCount;
     _maxCount         = other._maxCount;
     _countType        = other._countType;
     _showAddButton    = other._showAddButton;
     _showRemoveButton = other._showRemoveButton;
 }