Skip to content

Commit 10b90c4

Browse files
committed
Keep Item Rotation configuration.
1 parent 35b9985 commit 10b90c4

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

Runtime/Scripts/Controls/ReorderableList/ReorderableList.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public class ReorderableList : MonoBehaviour
3232
[Tooltip("Should items being dragged over this list have their sizes equalized?")]
3333
public bool EqualizeSizesOnDrag = false;
3434

35+
[Tooltip("Should items keep the original rotation?")]
36+
public bool KeepItemRotation = false;
37+
3538
[Tooltip("Maximum number of items this container can hold")]
3639
public int maxItems = int.MaxValue;
3740

Runtime/Scripts/Controls/ReorderableList/ReorderableListElement.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,10 @@ private void displaceElement(int targetIndex, Transform displaced)
266266
_displacedObjectLE.preferredWidth = _draggingObjectOriginalSize.x;
267267
_displacedObjectLE.preferredHeight = _draggingObjectOriginalSize.y;
268268
_displacedObject.SetParent(_reorderableList.Content, false);
269-
_displacedObject.rotation = _reorderableList.transform.rotation;
269+
if (!_reorderableList.KeepItemRotation)
270+
{
271+
_displacedObject.rotation = _reorderableList.transform.rotation;
272+
}
270273
_displacedObject.SetSiblingIndex(_fromIndex);
271274
// Force refreshing both lists because otherwise we get inappropriate FromList in ReorderableListEventStruct
272275
_reorderableList.Refresh();
@@ -310,7 +313,10 @@ private void revertDisplacedElement()
310313
_displacedObjectLE.preferredWidth = _displacedObjectOriginalSize.x;
311314
_displacedObjectLE.preferredHeight = _displacedObjectOriginalSize.y;
312315
_displacedObject.SetParent(_displacedObjectOriginList.Content, false);
313-
_displacedObject.rotation = _displacedObjectOriginList.transform.rotation;
316+
if (!_reorderableList.KeepItemRotation)
317+
{
318+
_displacedObject.rotation = _displacedObjectOriginList.transform.rotation;
319+
}
314320
_displacedObject.SetSiblingIndex(_displacedFromIndex);
315321
_displacedObject.gameObject.SetActive(true);
316322

@@ -382,7 +388,10 @@ public void OnEndDrag(PointerEventData eventData)
382388

383389
RefreshSizes();
384390
_draggingObject.SetParent(_currentReorderableListRaycasted.Content, false);
385-
_draggingObject.rotation = _currentReorderableListRaycasted.transform.rotation;
391+
if (!_reorderableList.KeepItemRotation)
392+
{
393+
_draggingObject.rotation = _currentReorderableListRaycasted.transform.rotation;
394+
}
386395
_draggingObject.SetSiblingIndex(_fakeElement.GetSiblingIndex());
387396

388397
//If the item is transferable, it can be dragged out again
@@ -474,7 +483,10 @@ private void CancelDrag()
474483
{
475484
RefreshSizes();
476485
_draggingObject.SetParent(_reorderableList.Content, false);
477-
_draggingObject.rotation = _reorderableList.Content.transform.rotation;
486+
if (!_reorderableList.KeepItemRotation)
487+
{
488+
_draggingObject.rotation = _reorderableList.Content.transform.rotation;
489+
}
478490
_draggingObject.SetSiblingIndex(_fromIndex);
479491

480492

0 commit comments

Comments
 (0)