@@ -13,12 +13,28 @@ namespace UnityEngine.UI.Extensions
1313 public class ReorderableListElement : MonoBehaviour , IDragHandler , IBeginDragHandler , IEndDragHandler
1414 {
1515 [ Tooltip ( "Can this element be dragged?" ) ]
16- public bool IsGrabbable = true ;
16+ [ SerializeField ]
17+ private bool IsGrabbable = true ;
18+
1719 [ Tooltip ( "Can this element be transfered to another list" ) ]
18- public bool IsTransferable = true ;
20+ [ SerializeField ]
21+ private bool _isTransferable = true ;
22+
1923 [ Tooltip ( "Can this element be dropped in space?" ) ]
20- public bool isDroppableInSpace = false ;
24+ [ SerializeField ]
25+ private bool isDroppableInSpace = false ;
26+
2127
28+ public bool IsTransferable
29+ {
30+ get { return _isTransferable ; }
31+ set
32+ {
33+ _canvasGroup = gameObject . GetOrAddComponent < CanvasGroup > ( ) ;
34+ _canvasGroup . blocksRaycasts = value ;
35+ _isTransferable = value ;
36+ }
37+ }
2238
2339 private readonly List < RaycastResult > _raycastResults = new List < RaycastResult > ( ) ;
2440 private ReorderableList _currentReorderableListRaycasted ;
@@ -48,6 +64,7 @@ public class ReorderableListElement : MonoBehaviour, IDragHandler, IBeginDragHan
4864
4965 public void OnBeginDrag ( PointerEventData eventData )
5066 {
67+ if ( ! _canvasGroup ) { _canvasGroup = gameObject . GetOrAddComponent < CanvasGroup > ( ) ; }
5168 _canvasGroup . blocksRaycasts = false ;
5269 isValid = true ;
5370 if ( _reorderableList == null )
@@ -162,7 +179,7 @@ public void OnDrag(PointerEventData eventData)
162179
163180 //If nothing found or the list is not dropable, put the fake element outside
164181 if ( _currentReorderableListRaycasted == null || _currentReorderableListRaycasted . IsDropable == false
165- || ( _oldReorderableListRaycasted != _reorderableList && ! IsTransferable )
182+ // || (_oldReorderableListRaycasted != _reorderableList && !IsTransferable)
166183 || ( ( _fakeElement . parent == _currentReorderableListRaycasted . Content
167184 ? _currentReorderableListRaycasted . Content . childCount - 1
168185 : _currentReorderableListRaycasted . Content . childCount ) >= _currentReorderableListRaycasted . maxItems && ! _currentReorderableListRaycasted . IsDisplacable )
@@ -378,13 +395,19 @@ public void OnEndDrag(PointerEventData eventData)
378395 _draggingObject . SetParent ( _currentReorderableListRaycasted . Content , false ) ;
379396 _draggingObject . rotation = _currentReorderableListRaycasted . transform . rotation ;
380397 _draggingObject . SetSiblingIndex ( _fakeElement . GetSiblingIndex ( ) ) ;
398+
399+ //If the item is transferable, it can be dragged out again
400+ if ( IsTransferable )
401+ {
402+ var cg = _draggingObject . GetComponent < CanvasGroup > ( ) ;
403+ cg . blocksRaycasts = true ;
404+ }
381405 // Force refreshing both lists because otherwise we get inappropriate FromList in ReorderableListEventStruct
382406 _reorderableList . Refresh ( ) ;
383407 _currentReorderableListRaycasted . Refresh ( ) ;
384408
385409 _reorderableList . OnElementAdded . Invoke ( args ) ;
386-
387-
410+
388411 if ( _displacedObject != null )
389412 {
390413 finishDisplacingElement ( ) ;
0 commit comments