void UIItemSlot.SlotInteractor.StopHover(UIItemSlot hovering, UIAbstractContainer overContainer, UIItemSlot over) { // TODO: If not compatible, do something other than un-highlighting if (over) { over.Highlighted = false; } else { overContainer.Highlighted = false; } }
void UIItemSlot.SlotInteractor.StartHover(UIItemSlot hovering, UIAbstractContainer overContainer, UIItemSlot over) { // TODO: Check if compatible, if not, do something other than highlighting. if (over) { over.Highlighted = true; } else { overContainer.Highlighted = true; } }
/** * Finds either the slot and container, or just container, or nothing, at the given point. */ public static UISlotRef FindSlotAtPointer(PointerEventData eventData) { // Check if hovering List <RaycastResult> results = new List <RaycastResult>(); EventSystem.current.RaycastAll(eventData, results); // Find what we might be hovering over UIAbstractContainer foundContainer = null; UIItemSlot foundSlot = null; foreach (var result in results) { var container = result.gameObject.GetComponent <UIAbstractContainer>(); if (container != null) { foundContainer = container; } var slot = result.gameObject.GetComponent <UIItemSlot>(); if (slot != null) { foundSlot = slot; } } // TODO: This is a hack that will be removed soon if (foundSlot && !foundContainer) { Transform obj = foundSlot.transform.parent; while (obj) { if (obj.GetComponent <UIAbstractContainer>()) { foundContainer = obj.GetComponent <UIAbstractContainer>(); break; } obj = obj.parent; } } UISlotRef slotRef; slotRef.container = foundContainer; slotRef.slot = foundSlot; return(slotRef); }
public UISlotRef(UIAbstractContainer container, UIItemSlot slot) { this.container = container; this.slot = slot; }