示例#1
0
        public static FoodTicket Create(Constants.FoodType food)
        {
            FoodTicket newTicket = Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/UI/FoodTicket")).GetComponent <FoodTicket>();

            newTicket.TargetFood = food;
            newTicket.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Sprites/UI/Foods/" + food.ToString());

            newTicket.transform.SetParent(null);

            return(newTicket);
        }
示例#2
0
        public void OnDrag(PointerEventData eventData)
        {
            float distance = eventData.position.DistanceWith(pointerDownPosition);

            if (distance > 50f && createdTicket == null)
            {
                createdTicket = FoodTicket.Create(FoodType);

                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;
            }
        }