Skip to content
Snippets Groups Projects
Commit 6c03e4f6 authored by Karim Ajouz's avatar Karim Ajouz
Browse files

Fixed Timeline Ordering Issue

parent 6c51ec52
Branches
No related merge requests found
...@@ -31,14 +31,14 @@ public class DragScript : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDr ...@@ -31,14 +31,14 @@ public class DragScript : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDr
EvidenceUI newEvScript = timelineElement.GetComponent<EvidenceUI>(); EvidenceUI newEvScript = timelineElement.GetComponent<EvidenceUI>();
var fields = newEvScript.GetType().GetFields(); var fields = newEvScript.GetType().GetFields();
foreach(var field in fields) foreach(var field in fields)
{ {
field.SetValue(newEvScript, field.GetValue(this.GetComponent<EvidenceUI>())); field.SetValue(newEvScript, field.GetValue(this.GetComponent<EvidenceUI>()));
} }
} }
public void OnDrag(PointerEventData eventData) public void OnDrag(PointerEventData eventData)
{ {
timelineElement.transform.position = eventData.position; timelineElement.transform.position = eventData.position;
...@@ -48,37 +48,37 @@ public class DragScript : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDr ...@@ -48,37 +48,37 @@ public class DragScript : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDr
for (int i = 0; i < timelineScript.corroborations.Count; i++) for (int i = 0; i < timelineScript.corroborations.Count; i++)
{ {
if (eventData.position.x < timelineArea.transform.GetChild(i).transform.position.x) if (eventData.position.x < timelineArea.GetComponentInChildren<ScrollRect>().gameObject.transform.GetChild(0).transform.GetChild(i).transform.position.x)
{ {
newSibIndex--; newSibIndex--;
} }
} }
Debug.Log(newSibIndex); Debug.Log(newSibIndex);
} }
public void OnEndDrag(PointerEventData eventData) public void OnEndDrag(PointerEventData eventData)
{ {
Debug.Log(placeHolderSibIndex); Debug.Log(placeHolderSibIndex);
if (eventData.position.x > (timelineArea.GetComponent<RectTransform>().rect.xMin + (timelineArea.GetComponent<RectTransform>().rect.width / 2)) && eventData.position.x < (timelineArea.GetComponent<RectTransform>().rect.xMax + (timelineArea.GetComponent<RectTransform>().rect.width / 2))) if (eventData.position.x > (timelineArea.GetComponent<RectTransform>().rect.xMin + (timelineArea.GetComponent<RectTransform>().rect.width / 2)) && eventData.position.x < (timelineArea.GetComponent<RectTransform>().rect.xMax + (timelineArea.GetComponent<RectTransform>().rect.width / 2)))
{ {
if (eventData.position.y > (timelineArea.GetComponent<RectTransform>().rect.yMin + (timelineArea.GetComponent<RectTransform>().rect.height / 2)) && eventData.position.y < (timelineArea.GetComponent<RectTransform>().rect.yMax + (timelineArea.GetComponent<RectTransform>().rect.height / 2))) if (eventData.position.y > (timelineArea.GetComponent<RectTransform>().rect.yMin + (timelineArea.GetComponent<RectTransform>().rect.height / 2)) && eventData.position.y < (timelineArea.GetComponent<RectTransform>().rect.yMax + (timelineArea.GetComponent<RectTransform>().rect.height / 2)))
{ {
timelineElement.transform.SetParent(timelineArea.GetComponentInChildren<ScrollRect>().gameObject.transform.GetChild(0)); timelineElement.transform.SetParent(timelineArea.GetComponentInChildren<ScrollRect>().gameObject.transform.GetChild(0));
timelineElement.transform.SetSiblingIndex(newSibIndex); timelineElement.transform.SetSiblingIndex(newSibIndex);
timelineScript.corroborations.Insert(newSibIndex, timelineElement); timelineScript.corroborations.Insert(newSibIndex, timelineElement);
} }
else else
{ {
Destroy(timelineElement); Destroy(timelineElement);
} }
} }
else else
{ {
Destroy(timelineElement); Destroy(timelineElement);
} }
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment