Newer
Older
John Schihada
committed
using UnityEngine;
public class DropHandling : MonoBehaviour, IDropHandler, IPointerClickHandler
John Schihada
committed
public void OnDrop(PointerEventData eventData)
{
var scrollFact = gameObject.GetComponent<RenderedScrollFact>();
Debug.Log(eventData.pointerDrag.GetComponent<FactWrapper>().fact.Label + " was dropped on "
+ gameObject.name + " " + scrollFact.ID + "/" +
ScrollDetails.ParameterDisplays.Count + " label: " + scrollFact.Label);
John Schihada
committed
current = Instantiate(eventData.pointerDrag, Vector3.zero, Quaternion.identity);
John Schihada
committed
//Set imageToChangeDefaultColor of current: Fix so that current won't take the color
//the dragged item was having during animation
current.GetComponent<ImageHintAnimation>().imageToChangeDefaultColor = eventData.pointerDrag.GetComponent<ImageHintAnimation>().imageToChangeDefaultColor;
current.GetComponent<ImageHintAnimation>().ResetAnimation();
John Schihada
committed
John Schihada
committed
var rect = current.GetComponent<RectTransform>();
rect.anchorMin = new Vector2(0.5f, 0.5f);
rect.anchorMax = new Vector2(0.5f, 0.5f);
currentFact = eventData.pointerDrag.GetComponent<FactWrapper>().fact;
current.GetComponent<FactWrapper>().fact = currentFact;
Marco Zimmer
committed
Debug.Log("recieved Fact: " + currentFact.Id);
CommunicationEvents.NewAssignmentEvent.Invoke();
public void OnPointerClick(PointerEventData eventData)
{
Destroy(current);
currentFact = null;
CommunicationEvents.NewAssignmentEvent.Invoke();
}