Merge pull request #479 from JavierMonton/release

Keep Item Rotation configuration.
pull/480/head^2
Simon (Darkside) Jackson 2024-10-02 13:18:31 +01:00 committed by GitHub
commit e5c329fa14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 4 deletions

View File

@ -32,6 +32,9 @@ namespace UnityEngine.UI.Extensions
[Tooltip("Should items being dragged over this list have their sizes equalized?")] [Tooltip("Should items being dragged over this list have their sizes equalized?")]
public bool EqualizeSizesOnDrag = false; public bool EqualizeSizesOnDrag = false;
[Tooltip("Should items keep the original rotation?")]
public bool KeepItemRotation = false;
[Tooltip("Maximum number of items this container can hold")] [Tooltip("Maximum number of items this container can hold")]
public int maxItems = int.MaxValue; public int maxItems = int.MaxValue;

View File

@ -266,7 +266,10 @@ namespace UnityEngine.UI.Extensions
_displacedObjectLE.preferredWidth = _draggingObjectOriginalSize.x; _displacedObjectLE.preferredWidth = _draggingObjectOriginalSize.x;
_displacedObjectLE.preferredHeight = _draggingObjectOriginalSize.y; _displacedObjectLE.preferredHeight = _draggingObjectOriginalSize.y;
_displacedObject.SetParent(_reorderableList.Content, false); _displacedObject.SetParent(_reorderableList.Content, false);
_displacedObject.rotation = _reorderableList.transform.rotation; if (!_reorderableList.KeepItemRotation)
{
_displacedObject.rotation = _reorderableList.transform.rotation;
}
_displacedObject.SetSiblingIndex(_fromIndex); _displacedObject.SetSiblingIndex(_fromIndex);
// Force refreshing both lists because otherwise we get inappropriate FromList in ReorderableListEventStruct // Force refreshing both lists because otherwise we get inappropriate FromList in ReorderableListEventStruct
_reorderableList.Refresh(); _reorderableList.Refresh();
@ -310,7 +313,10 @@ namespace UnityEngine.UI.Extensions
_displacedObjectLE.preferredWidth = _displacedObjectOriginalSize.x; _displacedObjectLE.preferredWidth = _displacedObjectOriginalSize.x;
_displacedObjectLE.preferredHeight = _displacedObjectOriginalSize.y; _displacedObjectLE.preferredHeight = _displacedObjectOriginalSize.y;
_displacedObject.SetParent(_displacedObjectOriginList.Content, false); _displacedObject.SetParent(_displacedObjectOriginList.Content, false);
_displacedObject.rotation = _displacedObjectOriginList.transform.rotation; if (!_reorderableList.KeepItemRotation)
{
_displacedObject.rotation = _displacedObjectOriginList.transform.rotation;
}
_displacedObject.SetSiblingIndex(_displacedFromIndex); _displacedObject.SetSiblingIndex(_displacedFromIndex);
_displacedObject.gameObject.SetActive(true); _displacedObject.gameObject.SetActive(true);
@ -382,7 +388,10 @@ namespace UnityEngine.UI.Extensions
RefreshSizes(); RefreshSizes();
_draggingObject.SetParent(_currentReorderableListRaycasted.Content, false); _draggingObject.SetParent(_currentReorderableListRaycasted.Content, false);
_draggingObject.rotation = _currentReorderableListRaycasted.transform.rotation; if (!_reorderableList.KeepItemRotation)
{
_draggingObject.rotation = _currentReorderableListRaycasted.transform.rotation;
}
_draggingObject.SetSiblingIndex(_fakeElement.GetSiblingIndex()); _draggingObject.SetSiblingIndex(_fakeElement.GetSiblingIndex());
//If the item is transferable, it can be dragged out again //If the item is transferable, it can be dragged out again
@ -474,7 +483,10 @@ namespace UnityEngine.UI.Extensions
{ {
RefreshSizes(); RefreshSizes();
_draggingObject.SetParent(_reorderableList.Content, false); _draggingObject.SetParent(_reorderableList.Content, false);
_draggingObject.rotation = _reorderableList.Content.transform.rotation; if (!_reorderableList.KeepItemRotation)
{
_draggingObject.rotation = _reorderableList.Content.transform.rotation;
}
_draggingObject.SetSiblingIndex(_fromIndex); _draggingObject.SetSiblingIndex(_fromIndex);