1st Pass update, Updated controls:
* DropDownList/ComboBox * Reorderable List (Screen Space Camera Updates * Curved text fixespull/413/head
parent
a09a5b5322
commit
dc809858b9
|
@ -37,7 +37,7 @@ RenderSettings:
|
||||||
m_ReflectionIntensity: 1
|
m_ReflectionIntensity: 1
|
||||||
m_CustomReflection: {fileID: 0}
|
m_CustomReflection: {fileID: 0}
|
||||||
m_Sun: {fileID: 0}
|
m_Sun: {fileID: 0}
|
||||||
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
|
m_IndirectSpecularColor: {r: 0.44657868, g: 0.49641263, b: 0.57481706, a: 1}
|
||||||
--- !u!157 &3
|
--- !u!157 &3
|
||||||
LightmapSettings:
|
LightmapSettings:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -756,9 +756,9 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 97a58789aa01843488ef44dc747ee8e8, type: 3}
|
m_Script: {fileID: 11500000, guid: 97a58789aa01843488ef44dc747ee8e8, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
useHalfCharWidth: 0
|
|
||||||
halfCharWidth: 0
|
|
||||||
m_spacing: 94.2
|
m_spacing: 94.2
|
||||||
|
HalfCharWidth: 1
|
||||||
|
UseHalfCharWidth: 0
|
||||||
--- !u!114 &755348327
|
--- !u!114 &755348327
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -985,7 +985,7 @@ RectTransform:
|
||||||
m_PrefabParentObject: {fileID: 0}
|
m_PrefabParentObject: {fileID: 0}
|
||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1101119004}
|
m_GameObject: {fileID: 1101119004}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
|
@ -1009,7 +1009,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 0ec526a95e7733b4396be80d3e1df80e, type: 3}
|
m_Script: {fileID: 11500000, guid: 0ec526a95e7733b4396be80d3e1df80e, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
radius: 121.96
|
radius: 98.31
|
||||||
--- !u!114 &1101119007
|
--- !u!114 &1101119007
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -1339,9 +1339,9 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 97a58789aa01843488ef44dc747ee8e8, type: 3}
|
m_Script: {fileID: 11500000, guid: 97a58789aa01843488ef44dc747ee8e8, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
useHalfCharWidth: 1
|
|
||||||
halfCharWidth: 4.55
|
|
||||||
m_spacing: 71.12
|
m_spacing: 71.12
|
||||||
|
HalfCharWidth: 1
|
||||||
|
UseHalfCharWidth: 0
|
||||||
--- !u!114 &1814753282
|
--- !u!114 &1814753282
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -76,8 +76,9 @@ namespace UnityEngine.UI.Extensions
|
||||||
public bool SelectFirstItemOnStart = false;
|
public bool SelectFirstItemOnStart = false;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
|
[Tooltip("Change input text color based on matching items")]
|
||||||
private bool _ChangeInputTextColorBasedOnMatchingItems = false;
|
private bool _ChangeInputTextColorBasedOnMatchingItems = false;
|
||||||
public bool ChangeInputTextColorBasedOnMatchingItems{
|
public bool InputColorMatching{
|
||||||
get { return _ChangeInputTextColorBasedOnMatchingItems; }
|
get { return _ChangeInputTextColorBasedOnMatchingItems; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
@ -100,7 +101,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class SelectinTextChangedEvent : UnityEngine.Events.UnityEvent<string> {
|
public class SelectionTextChangedEvent : UnityEngine.Events.UnityEvent<string> {
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
|
@ -108,14 +109,12 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
|
|
||||||
// fires when input text is changed;
|
// fires when input text is changed;
|
||||||
public SelectinTextChangedEvent OnSelectinTextChanged;
|
public SelectionTextChangedEvent OnSelectionTextChanged;
|
||||||
// fires when when an Item gets selected / deselected (including when items are added/removed once this is possible)
|
// fires when when an Item gets selected / deselected (including when items are added/removed once this is possible)
|
||||||
public SelectionValidityChangedEvent OnSelectionValidityChanged;
|
public SelectionValidityChangedEvent OnSelectionValidityChanged;
|
||||||
// fires in both cases
|
// fires in both cases
|
||||||
public SelectionChangedEvent OnSelectionChanged;
|
public SelectionChangedEvent OnSelectionChanged;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void Awake()
|
public void Awake()
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
|
@ -354,7 +353,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
bool validity_changed = (_panelItems.Contains (Text) == _selectionIsValid);
|
bool validity_changed = (_panelItems.Contains (Text) == _selectionIsValid);
|
||||||
_selectionIsValid = _panelItems.Contains (Text);
|
_selectionIsValid = _panelItems.Contains (Text);
|
||||||
OnSelectionChanged.Invoke (Text, _selectionIsValid);
|
OnSelectionChanged.Invoke (Text, _selectionIsValid);
|
||||||
OnSelectinTextChanged.Invoke (Text);
|
OnSelectionTextChanged.Invoke (Text);
|
||||||
if(validity_changed){
|
if(validity_changed){
|
||||||
OnSelectionValidityChanged.Invoke (_selectionIsValid);
|
OnSelectionValidityChanged.Invoke (_selectionIsValid);
|
||||||
}
|
}
|
||||||
|
@ -363,7 +362,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetInputTextColor(){
|
private void SetInputTextColor(){
|
||||||
if (ChangeInputTextColorBasedOnMatchingItems) {
|
if (InputColorMatching) {
|
||||||
if (_selectionIsValid) {
|
if (_selectionIsValid) {
|
||||||
_mainInput.textComponent.color = ValidSelectionTextColor;
|
_mainInput.textComponent.color = ValidSelectionTextColor;
|
||||||
} else if (_panelItems.Count > 0) {
|
} else if (_panelItems.Count > 0) {
|
||||||
|
|
|
@ -15,7 +15,18 @@ namespace UnityEngine.UI.Extensions
|
||||||
|
|
||||||
public List<string> AvailableOptions;
|
public List<string> AvailableOptions;
|
||||||
|
|
||||||
public System.Action<int> OnSelectionChanged; // fires when selection is changed;
|
[SerializeField]
|
||||||
|
private float _scrollBarWidth = 20.0f;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private int _itemsToDisplay;
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class SelectionChangedEvent : UnityEngine.Events.UnityEvent<string>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
// fires when item is changed;
|
||||||
|
public SelectionChangedEvent OnSelectionChanged;
|
||||||
|
|
||||||
//private bool isInitialized = false;
|
//private bool isInitialized = false;
|
||||||
private bool _isPanelActive = false;
|
private bool _isPanelActive = false;
|
||||||
|
@ -46,8 +57,6 @@ namespace UnityEngine.UI.Extensions
|
||||||
|
|
||||||
public string Text { get; private set; }
|
public string Text { get; private set; }
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
private float _scrollBarWidth = 20.0f;
|
|
||||||
public float ScrollBarWidth
|
public float ScrollBarWidth
|
||||||
{
|
{
|
||||||
get { return _scrollBarWidth; }
|
get { return _scrollBarWidth; }
|
||||||
|
@ -61,8 +70,6 @@ namespace UnityEngine.UI.Extensions
|
||||||
// private int scrollOffset; //offset of the selected item
|
// private int scrollOffset; //offset of the selected item
|
||||||
// private int _selectedIndex = 0;
|
// private int _selectedIndex = 0;
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
private int _itemsToDisplay;
|
|
||||||
public int ItemsToDisplay
|
public int ItemsToDisplay
|
||||||
{
|
{
|
||||||
get { return _itemsToDisplay; }
|
get { return _itemsToDisplay; }
|
||||||
|
@ -294,6 +301,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
ToggleDropdownPanel(false);
|
ToggleDropdownPanel(false);
|
||||||
}
|
}
|
||||||
|
OnSelectionChanged.Invoke(Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -79,8 +79,6 @@ namespace UnityEngine.UI.Extensions
|
||||||
public SelectionChangedEvent OnSelectionChanged;
|
public SelectionChangedEvent OnSelectionChanged;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
/// Sourced from - http://forum.unity3d.com/threads/free-reorderable-list.364600/
|
/// Sourced from - http://forum.unity3d.com/threads/free-reorderable-list.364600/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine.Events;
|
using UnityEngine.Events;
|
||||||
|
|
||||||
namespace UnityEngine.UI.Extensions
|
namespace UnityEngine.UI.Extensions
|
||||||
|
@ -28,6 +30,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
public ReorderableListHandler OnElementDropped = new ReorderableListHandler();
|
public ReorderableListHandler OnElementDropped = new ReorderableListHandler();
|
||||||
public ReorderableListHandler OnElementGrabbed = new ReorderableListHandler();
|
public ReorderableListHandler OnElementGrabbed = new ReorderableListHandler();
|
||||||
public ReorderableListHandler OnElementRemoved = new ReorderableListHandler();
|
public ReorderableListHandler OnElementRemoved = new ReorderableListHandler();
|
||||||
|
public ReorderableListHandler OnElementAdded = new ReorderableListHandler();
|
||||||
|
|
||||||
private RectTransform _content;
|
private RectTransform _content;
|
||||||
private ReorderableListContent _listContent;
|
private ReorderableListContent _listContent;
|
||||||
|
@ -83,9 +86,9 @@ namespace UnityEngine.UI.Extensions
|
||||||
Debug.LogError("You need to have a Graphic control (such as an Image) for the list [" + name + "] to be droppable", gameObject);
|
Debug.LogError("You need to have a Graphic control (such as an Image) for the list [" + name + "] to be droppable", gameObject);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (GetCanvas().renderMode != RenderMode.ScreenSpaceOverlay)
|
if (GetCanvas().renderMode > RenderMode.ScreenSpaceCamera)
|
||||||
{
|
{
|
||||||
Debug.LogError("The ReOrderable List is only supported on a Screenspace-Overlay Canvas at the moment");
|
Debug.LogError("The ReOrderable List is only supported on a Screen-Space Canvas at the moment");
|
||||||
}
|
}
|
||||||
|
|
||||||
_listContent = ContentLayout.gameObject.AddComponent<ReorderableListContent>();
|
_listContent = ContentLayout.gameObject.AddComponent<ReorderableListContent>();
|
||||||
|
@ -104,6 +107,11 @@ namespace UnityEngine.UI.Extensions
|
||||||
public GameObject SourceObject;
|
public GameObject SourceObject;
|
||||||
public int ToIndex;
|
public int ToIndex;
|
||||||
public ReorderableList ToList;
|
public ReorderableList ToList;
|
||||||
|
|
||||||
|
public void Cancel()
|
||||||
|
{
|
||||||
|
SourceObject.GetComponent<ReorderableListElement>().isValid = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 6b333d67eb08d464d823874f6a1666c2
|
guid: 6b333d67eb08d464d823874f6a1666c2
|
||||||
timeCreated: 1446072130
|
timeCreated: 1492560112
|
||||||
licenseType: Pro
|
licenseType: Free
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
|
|
|
@ -14,9 +14,15 @@ namespace UnityEngine.UI.Extensions
|
||||||
private ReorderableList _extList;
|
private ReorderableList _extList;
|
||||||
private RectTransform _rect;
|
private RectTransform _rect;
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
if(_rect)StartCoroutine(RefreshChildren());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void OnTransformChildrenChanged()
|
public void OnTransformChildrenChanged()
|
||||||
{
|
{
|
||||||
StartCoroutine(RefreshChildren());
|
if(this.isActiveAndEnabled)StartCoroutine(RefreshChildren());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init(ReorderableList extList)
|
public void Init(ReorderableList extList)
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
/// Sourced from - http://forum.unity3d.com/threads/free-reorderable-list.364600/
|
/// Sourced from - http://forum.unity3d.com/threads/free-reorderable-list.364600/
|
||||||
/// Last Child Fix - https://bitbucket.org/ddreaper/unity-ui-extensions/issues/70/all-re-orderable-lists-cause-a-transform
|
/// Last Child Fix - https://bitbucket.org/ddreaper/unity-ui-extensions/issues/70/all-re-orderable-lists-cause-a-transform
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
namespace UnityEngine.UI.Extensions
|
namespace UnityEngine.UI.Extensions
|
||||||
|
@ -11,6 +13,14 @@ namespace UnityEngine.UI.Extensions
|
||||||
[RequireComponent(typeof(RectTransform))]
|
[RequireComponent(typeof(RectTransform))]
|
||||||
public class ReorderableListElement : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDragHandler
|
public class ReorderableListElement : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDragHandler
|
||||||
{
|
{
|
||||||
|
[Tooltip("Can this element be dragged?")]
|
||||||
|
public bool IsGrabbable = true;
|
||||||
|
[Tooltip("Can this element be transfered to another list")]
|
||||||
|
public bool IsTransferable = true;
|
||||||
|
[Tooltip("Can this element be dropped in space?")]
|
||||||
|
public bool isDroppableInSpace = false;
|
||||||
|
|
||||||
|
|
||||||
private readonly List<RaycastResult> _raycastResults = new List<RaycastResult>();
|
private readonly List<RaycastResult> _raycastResults = new List<RaycastResult>();
|
||||||
private ReorderableList _currentReorderableListRaycasted;
|
private ReorderableList _currentReorderableListRaycasted;
|
||||||
private RectTransform _draggingObject;
|
private RectTransform _draggingObject;
|
||||||
|
@ -22,16 +32,18 @@ namespace UnityEngine.UI.Extensions
|
||||||
private bool _isDragging;
|
private bool _isDragging;
|
||||||
private RectTransform _rect;
|
private RectTransform _rect;
|
||||||
private ReorderableList _reorderableList;
|
private ReorderableList _reorderableList;
|
||||||
|
internal bool isValid;
|
||||||
|
|
||||||
#region IBeginDragHandler Members
|
#region IBeginDragHandler Members
|
||||||
|
|
||||||
public void OnBeginDrag(PointerEventData eventData)
|
public void OnBeginDrag(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
|
isValid = true;
|
||||||
if (_reorderableList == null)
|
if (_reorderableList == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Can't drag, return...
|
//Can't drag, return...
|
||||||
if (!_reorderableList.IsDraggable)
|
if (!_reorderableList.IsDraggable || !this.IsGrabbable)
|
||||||
{
|
{
|
||||||
_draggingObject = null;
|
_draggingObject = null;
|
||||||
return;
|
return;
|
||||||
|
@ -54,6 +66,11 @@ namespace UnityEngine.UI.Extensions
|
||||||
FromIndex = _fromIndex,
|
FromIndex = _fromIndex,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (isValid == false)
|
||||||
|
{
|
||||||
|
_draggingObject = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//Else Duplicate
|
//Else Duplicate
|
||||||
else
|
else
|
||||||
|
@ -86,6 +103,12 @@ namespace UnityEngine.UI.Extensions
|
||||||
FromList = _reorderableList,
|
FromList = _reorderableList,
|
||||||
FromIndex = _fromIndex,
|
FromIndex = _fromIndex,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
CancelDrag();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_isDragging = true;
|
_isDragging = true;
|
||||||
|
@ -99,9 +122,17 @@ namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
if (!_isDragging)
|
if (!_isDragging)
|
||||||
return;
|
return;
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
CancelDrag();
|
||||||
|
return;
|
||||||
|
}
|
||||||
//Set dragging object on cursor
|
//Set dragging object on cursor
|
||||||
_draggingObject.position = eventData.position;
|
var canvas = _draggingObject.GetComponentInParent<Canvas>();
|
||||||
|
Vector3 worldPoint;
|
||||||
|
RectTransformUtility.ScreenPointToWorldPointInRectangle(canvas.GetComponent<RectTransform>(), eventData.position,
|
||||||
|
canvas.worldCamera, out worldPoint);
|
||||||
|
_draggingObject.position = worldPoint;
|
||||||
|
|
||||||
//Check everything under the cursor to find a ReorderableList
|
//Check everything under the cursor to find a ReorderableList
|
||||||
EventSystem.current.RaycastAll(eventData, _raycastResults);
|
EventSystem.current.RaycastAll(eventData, _raycastResults);
|
||||||
|
@ -135,11 +166,11 @@ namespace UnityEngine.UI.Extensions
|
||||||
var c = _currentReorderableListRaycasted.Content.GetChild(j).GetComponent<RectTransform>();
|
var c = _currentReorderableListRaycasted.Content.GetChild(j).GetComponent<RectTransform>();
|
||||||
|
|
||||||
if (_currentReorderableListRaycasted.ContentLayout is VerticalLayoutGroup)
|
if (_currentReorderableListRaycasted.ContentLayout is VerticalLayoutGroup)
|
||||||
dist = Mathf.Abs(c.position.y - eventData.position.y);
|
dist = Mathf.Abs(c.position.y - worldPoint.y);
|
||||||
else if (_currentReorderableListRaycasted.ContentLayout is HorizontalLayoutGroup)
|
else if (_currentReorderableListRaycasted.ContentLayout is HorizontalLayoutGroup)
|
||||||
dist = Mathf.Abs(c.position.x - eventData.position.x);
|
dist = Mathf.Abs(c.position.x - worldPoint.x);
|
||||||
else if (_currentReorderableListRaycasted.ContentLayout is GridLayoutGroup)
|
else if (_currentReorderableListRaycasted.ContentLayout is GridLayoutGroup)
|
||||||
dist = (Mathf.Abs(c.position.x - eventData.position.x) + Mathf.Abs(c.position.y - eventData.position.y));
|
dist = (Mathf.Abs(c.position.x - worldPoint.x) + Mathf.Abs(c.position.y - worldPoint.y));
|
||||||
|
|
||||||
if (dist < minDistance)
|
if (dist < minDistance)
|
||||||
{
|
{
|
||||||
|
@ -167,17 +198,10 @@ namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
//If we have a, ReorderableList that is dropable
|
//If we have a, ReorderableList that is dropable
|
||||||
//Put the dragged object into the content and at the right index
|
//Put the dragged object into the content and at the right index
|
||||||
if (_currentReorderableListRaycasted != null && _currentReorderableListRaycasted.IsDropable)
|
if (_currentReorderableListRaycasted != null && _currentReorderableListRaycasted.IsDropable
|
||||||
|
&& (IsTransferable || _currentReorderableListRaycasted == _reorderableList ))
|
||||||
{
|
{
|
||||||
RefreshSizes();
|
var args = new ReorderableList.ReorderableListEventStruct
|
||||||
_draggingObject.SetParent(_currentReorderableListRaycasted.Content, false);
|
|
||||||
_draggingObject.SetSiblingIndex(_fakeElement.GetSiblingIndex());
|
|
||||||
|
|
||||||
|
|
||||||
//Send OnelementDropped Event
|
|
||||||
if (_reorderableList.OnElementDropped != null)
|
|
||||||
{
|
|
||||||
_reorderableList.OnElementDropped.Invoke(new ReorderableList.ReorderableListEventStruct
|
|
||||||
{
|
{
|
||||||
DroppedObject = _draggingObject.gameObject,
|
DroppedObject = _draggingObject.gameObject,
|
||||||
IsAClone = _reorderableList.CloneDraggedObject,
|
IsAClone = _reorderableList.CloneDraggedObject,
|
||||||
|
@ -185,13 +209,59 @@ namespace UnityEngine.UI.Extensions
|
||||||
FromList = _reorderableList,
|
FromList = _reorderableList,
|
||||||
FromIndex = _fromIndex,
|
FromIndex = _fromIndex,
|
||||||
ToList = _currentReorderableListRaycasted,
|
ToList = _currentReorderableListRaycasted,
|
||||||
ToIndex = _fakeElement.GetSiblingIndex() - 1
|
ToIndex = _fakeElement.GetSiblingIndex()
|
||||||
});
|
};
|
||||||
|
//Send OnelementDropped Event
|
||||||
|
if (_reorderableList && _reorderableList.OnElementDropped != null)
|
||||||
|
{
|
||||||
|
_reorderableList.OnElementDropped.Invoke(args);
|
||||||
}
|
}
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
CancelDrag();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
RefreshSizes();
|
||||||
|
_draggingObject.SetParent(_currentReorderableListRaycasted.Content, false);
|
||||||
|
_draggingObject.SetSiblingIndex(_fakeElement.GetSiblingIndex());
|
||||||
|
|
||||||
|
_reorderableList.OnElementAdded.Invoke(args);
|
||||||
|
|
||||||
|
if(!isValid) throw new Exception("It's too late to cancel the Transfer! Do so in OnElementDropped!");
|
||||||
|
|
||||||
}
|
}
|
||||||
//We don't have an ReorderableList
|
//We don't have an ReorderableList
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (this.isDroppableInSpace)
|
||||||
|
{
|
||||||
|
_reorderableList.OnElementDropped.Invoke(new ReorderableList.ReorderableListEventStruct
|
||||||
|
{
|
||||||
|
DroppedObject = _draggingObject.gameObject,
|
||||||
|
IsAClone = _reorderableList.CloneDraggedObject,
|
||||||
|
SourceObject =
|
||||||
|
_reorderableList.CloneDraggedObject ? gameObject : _draggingObject.gameObject,
|
||||||
|
FromList = _reorderableList,
|
||||||
|
FromIndex = _fromIndex
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CancelDrag();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Delete fake element
|
||||||
|
if (_fakeElement != null)
|
||||||
|
Destroy(_fakeElement.gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
void CancelDrag()
|
||||||
|
{
|
||||||
|
_isDragging = false;
|
||||||
//If it's a clone, delete it
|
//If it's a clone, delete it
|
||||||
if (_reorderableList.CloneDraggedObject)
|
if (_reorderableList.CloneDraggedObject)
|
||||||
{
|
{
|
||||||
|
@ -203,8 +273,24 @@ namespace UnityEngine.UI.Extensions
|
||||||
RefreshSizes();
|
RefreshSizes();
|
||||||
_draggingObject.SetParent(_reorderableList.Content, false);
|
_draggingObject.SetParent(_reorderableList.Content, false);
|
||||||
_draggingObject.SetSiblingIndex(_fromIndex);
|
_draggingObject.SetSiblingIndex(_fromIndex);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
var args = new ReorderableList.ReorderableListEventStruct
|
||||||
|
{
|
||||||
|
DroppedObject = _draggingObject.gameObject,
|
||||||
|
IsAClone = _reorderableList.CloneDraggedObject,
|
||||||
|
SourceObject = _reorderableList.CloneDraggedObject ? gameObject : _draggingObject.gameObject,
|
||||||
|
FromList = _reorderableList,
|
||||||
|
FromIndex = _fromIndex,
|
||||||
|
ToList = _reorderableList,
|
||||||
|
ToIndex = _fromIndex
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
_reorderableList.OnElementAdded.Invoke(args);
|
||||||
|
|
||||||
|
if (!isValid) throw new Exception("Transfer is already Cancelled.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Delete fake element
|
//Delete fake element
|
||||||
|
@ -212,8 +298,6 @@ namespace UnityEngine.UI.Extensions
|
||||||
Destroy(_fakeElement.gameObject);
|
Destroy(_fakeElement.gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private void RefreshSizes()
|
private void RefreshSizes()
|
||||||
{
|
{
|
||||||
Vector2 size = _draggingObjectOriginalSize;
|
Vector2 size = _draggingObjectOriginalSize;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 916e98f1b982a9a4082fcc45c87b66c5
|
guid: 916e98f1b982a9a4082fcc45c87b66c5
|
||||||
timeCreated: 1446072130
|
timeCreated: 1492560112
|
||||||
licenseType: Pro
|
licenseType: Free
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
|
|
|
@ -57,9 +57,12 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
protected override void OnRectTransformDimensionsChange()
|
protected override void OnRectTransformDimensionsChange()
|
||||||
{
|
{
|
||||||
var tmpRect = curveForText[curveForText.length - 1];
|
if (rectTrans)
|
||||||
|
{
|
||||||
|
Keyframe tmpRect = curveForText[curveForText.length - 1];
|
||||||
tmpRect.time = rectTrans.rect.width;
|
tmpRect.time = rectTrans.rect.width;
|
||||||
curveForText.MoveKey(curveForText.length - 1, tmpRect);
|
curveForText.MoveKey(curveForText.length - 1, tmpRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue