diff --git a/Scripts/Controls/ReorderableList/ReorderableList.cs b/Scripts/Controls/ReorderableList/ReorderableList.cs index 30e256e..188cd86 100644 --- a/Scripts/Controls/ReorderableList/ReorderableList.cs +++ b/Scripts/Controls/ReorderableList/ReorderableList.cs @@ -41,6 +41,7 @@ namespace UnityEngine.UI.Extensions public ReorderableListHandler OnElementDisplacedTo = new ReorderableListHandler(); public ReorderableListHandler OnElementDisplacedFromReturned = new ReorderableListHandler(); public ReorderableListHandler OnElementDisplacedToReturned = new ReorderableListHandler(); + public ReorderableListHandler OnElementDroppedWithMaxItems = new ReorderableListHandler(); private RectTransform _content; private ReorderableListContent _listContent; diff --git a/Scripts/Controls/ReorderableList/ReorderableListElement.cs b/Scripts/Controls/ReorderableList/ReorderableListElement.cs index 4c227fe..5db86bf 100644 --- a/Scripts/Controls/ReorderableList/ReorderableListElement.cs +++ b/Scripts/Controls/ReorderableList/ReorderableListElement.cs @@ -392,12 +392,11 @@ namespace UnityEngine.UI.Extensions if (!isValid) throw new Exception("It's too late to cancel the Transfer! Do so in OnElementDropped!"); - - } - //We don't have an ReorderableList + else { + //We don't have an ReorderableList if (this.isDroppableInSpace) { _reorderableList.OnElementDropped.Invoke(new ReorderableList.ReorderableListEventStruct @@ -414,6 +413,29 @@ namespace UnityEngine.UI.Extensions { CancelDrag(); } + + //If there is no more room for the element in the target list, notify it (OnElementDroppedWithMaxItems event) + if (_currentReorderableListRaycasted != null) + { + if ((_currentReorderableListRaycasted.Content.childCount >= + _currentReorderableListRaycasted.maxItems && + !_currentReorderableListRaycasted.IsDisplacable) + || _currentReorderableListRaycasted.maxItems <= 0) + { + GameObject o = _draggingObject.gameObject; + _reorderableList.OnElementDroppedWithMaxItems.Invoke( + new ReorderableList.ReorderableListEventStruct + { + DroppedObject = o, + IsAClone = _reorderableList.CloneDraggedObject, + SourceObject = _reorderableList.CloneDraggedObject ? gameObject : o, + FromList = _reorderableList, + ToList = _currentReorderableListRaycasted, + FromIndex = _fromIndex + }); + } + } + } }