Skip to content
Snippets Groups Projects
DropHandling.cs 1.11 KiB
Newer Older
  • Learn to ignore specific revisions
  • BenniHome's avatar
    BenniHome committed
    using UnityEngine.EventSystems;
    
    
    public class DropHandling : MonoBehaviour, IDropHandler, IPointerClickHandler
    
    BenniHome's avatar
    BenniHome committed
    {
        GameObject current;
    
        public Fact currentFact;
    
    BenniHome's avatar
    BenniHome committed
        public void OnDrop(PointerEventData eventData){
    
    Richard Marcus's avatar
    Richard Marcus committed
            
    
    Richard Marcus's avatar
    Richard Marcus committed
            var scrollFact = gameObject.GetComponent<RenderedScrollFact>();
    
    Richard Marcus's avatar
    Richard Marcus committed
            Debug.Log(eventData.pointerDrag.GetComponent<FactWrapper>().fact.Label+ " was dropped on "
                + gameObject.name+ " " +scrollFact.ID + "/" +
                ScrollDetails.ParameterDisplays.Count+" label: "+scrollFact.Label);
    
    BenniHome's avatar
    BenniHome committed
            Destroy(current);
    
    BenniHome's avatar
    BenniHome committed
            current = Instantiate(eventData.pointerDrag,Vector3.zero, Quaternion.identity);
    
    BenniHome's avatar
    BenniHome committed
            current.transform.SetParent(gameObject.transform, false);
    
            currentFact = eventData.pointerDrag.GetComponent<FactWrapper>().fact;
            Debug.Log("recieved Fact: " + currentFact.backendURI);
    
            CommunicationEvents.NewAssignmentEvent.Invoke();
    
    BenniHome's avatar
    BenniHome committed
        }
    
    
        public void OnPointerClick(PointerEventData eventData) {
            Destroy(current);
            currentFact = null;
            CommunicationEvents.NewAssignmentEvent.Invoke();
        }
    
    
    BenniHome's avatar
    BenniHome committed
    }