public static FacilityTicket Create(Constants.FacilityType facility) { FacilityTicket newTicket = Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/UI/FacilityTicket")).GetComponent <FacilityTicket>(); newTicket.TargetFacility = facility; newTicket.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Sprites/UI/Facilities/" + facility.ToString()); newTicket.transform.SetParent(null); return(newTicket); }
public void OnDrag(PointerEventData eventData) { float distance = eventData.position.DistanceWith(pointerDownPosition); if (distance > 50f && createdTicket == null) { createdTicket = FacilityTicket.Create(FailityType); createdTicket.GetComponent <DragTarget>().IsDraggable = true; ExecuteEvents.Execute <IBeginDragHandler>(createdTicket.gameObject, eventData, ExecuteEvents.beginDragHandler); ExecuteEvents.Execute <IEndDragHandler>(this.gameObject, eventData, ExecuteEvents.endDragHandler); eventData.pointerEnter = null; eventData.pointerDrag = createdTicket.gameObject; } }