Exemplo n.º 1
0
 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;
     }
 }
Exemplo n.º 2
0
 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;
     }
 }
Exemplo n.º 3
0
        /**
         * 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);
        }
Exemplo n.º 4
0
 public UISlotRef(UIAbstractContainer container, UIItemSlot slot)
 {
     this.container = container;
     this.slot      = slot;
 }