protected override void OnDraggableEndDrag(PointerEventData eventData) { if (!dragWith.Contains(eventData.button)) { return; } // See if this is was left over a rycast-blocking drop space. List <RaycastResult> hits = new List <RaycastResult>(); gRaycaster.Raycast(eventData, hits); InventoryDropSpace dropSpace = null; bool hitDropSpace = false; foreach (RaycastResult hit in hits) { dropSpace = hit.gameObject.GetComponent <InventoryDropSpace>(); if (dropSpace != null) { break; } } // If not, put it back where it was. Otherwise, let the drop area handle the rest. if (!hitDropSpace) { ResetParent(); } SlotDragEnd.Invoke(); base.OnDraggableDrag(eventData); }
// Use this for self-initialization protected override void Awake() { base.Awake(); gRaycaster = GameObject.FindObjectOfType <GraphicRaycaster>(); EnsureComponents(); SlotDragBegin.AddListener(OnSlotDragBegin); SlotDragEnd.AddListener(OnSlotDragEnd); }