当前位置: 首页>>代码示例>>C#>>正文


C# PointerEventData.Use方法代码示例

本文整理汇总了C#中UnityEngine.EventSystems.PointerEventData.Use方法的典型用法代码示例。如果您正苦于以下问题:C# PointerEventData.Use方法的具体用法?C# PointerEventData.Use怎么用?C# PointerEventData.Use使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.EventSystems.PointerEventData的用法示例。


在下文中一共展示了PointerEventData.Use方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnDrop

        /// <summary>
        /// When this slot gets an item dropped on it,
        /// it verifies that it is of the same ItemType.
        /// If so, it adds the item to the slot.If not,
        /// it uses the eventData as the drop was successful.
        /// </summary>
        /// <param name="eventData">The `PointerEventData` of the event</param>
        public override void OnDrop(PointerEventData eventData)
        {
            DraggableItemType itemType = Draggable.DraggedItem.GetComponent<DraggableItemType>();

            if (itemType == null) {
                eventData.Use();
                return;
            }

            if (itemType.ItemType == Type) {
                base.OnDrop(eventData);
            } else {
                eventData.Use();
            }
        }
开发者ID:adampassey,项目名称:collect,代码行数:22,代码来源:SlotWithType.cs

示例2: OnBeginDrag

        public override void OnBeginDrag(PointerEventData eventData)
        {
            if (!interactable)
            {
                return;
            }

            //Debug.Log("OnBeginDrag (isFocused: {0}, isUsed: {1}, delta: {2})".Fmt(isFocused, eventData.used, eventData.delta));

            // Pass event to parent if it is a vertical drag
            if (Mathf.Abs(eventData.delta.y) > Mathf.Abs(eventData.delta.x))
            {
                //Debug.Log("Passing To Parent");

                var parent = transform.parent;

                if (parent != null)
                {
                    eventData.pointerDrag = ExecuteEvents.GetEventHandler<IBeginDragHandler>(parent.gameObject);

                    if (eventData.pointerDrag != null)
                    {
                        ExecuteEvents.Execute(eventData.pointerDrag, eventData, ExecuteEvents.beginDragHandler);
                    }
                }

                return;
            }
            eventData.Use();

            _dragStartAmount = double.Parse(text);
            _currentValue = _dragStartAmount;

            var minStep = 1f;

            // Use a larger minimum step for integer numbers, since there are no fractional values
            if (contentType == ContentType.IntegerNumber)
            {
                minStep *= 10;
            }

            _dragStep = Math.Max(minStep, _dragStartAmount*0.05f);

            if (isFocused)
            {
                DeactivateInputField();
            }
        }
开发者ID:TripleLoopGames,项目名称:space-roaches,代码行数:48,代码来源:SRNumberSpinner.cs

示例3: OnEndDrag

        /// <summary>
        /// Raises the end drag event.
        /// </summary>
        /// <param name="eventData">Event data.</param>
        public virtual void OnEndDrag(PointerEventData eventData)
        {
            // Check if a drag was initialized at all
            if (!this.m_DragHasBegan)
                return;

            // Reset the drag begin bool
            this.m_DragHasBegan = false;

            // Destroy the dragged icon object
            if (this.m_CurrentDraggedObject != null)
            {
                Destroy(this.m_CurrentDraggedObject);
            }

            // Reset the variables
            this.m_CurrentDraggedObject = null;
            this.m_CurrentDraggingPlane = null;

            // Use the event
            eventData.Use();

            // Check if we are returning the icon to the same slot
            // By checking if the slot is highlighted
            if (this.IsHighlighted(eventData))
                return;

            // Check if no drop was preformed
            if (!this.m_DropPreformed)
            {
                // Try to throw away the assigned content
                this.OnThrowAway();
            }
            else
            {
                // Reset the drop preformed variable
                this.m_DropPreformed = false;
            }
        }
开发者ID:DevDanSTL,项目名称:ggj2016,代码行数:43,代码来源:UISlotBase.cs

示例4: OnDrop

        /// <summary>
        /// Raises the drop event.
        /// </summary>
        /// <param name="eventData">Event data.</param>
        public virtual void OnDrop(PointerEventData eventData)
        {
            // Get the source slot
            UISlotBase source = (eventData.pointerPress != null) ? eventData.pointerPress.GetComponent<UISlotBase>() : null;

            // Make sure we have the source slot and it's assigned
            if (source == null || !source.IsAssigned())
                return;

            // Notify the source that a drop was performed so it does not unassign
            source.dropPreformed = true;

            // Check if this slot is enabled and it's drag and drop feature is enabled
            if (!this.enabled || !this.m_DragAndDropEnabled)
                return;

            // Prepare a variable indicating whether the assign process was successful
            bool assignSuccess = false;

            // Normal empty slot assignment
            if (!this.IsAssigned())
            {
                // Assign the target slot with the info from the source
                assignSuccess = this.Assign(source);

                // Unassign the source on successful assignment and the source is not static
                if (assignSuccess && !source.isStatic)
                    source.Unassign();
            }
            // The target slot is assigned
            else
            {
                // If the target slot is not static
                // and we have a source slot that is not static
                if (!this.isStatic && !source.isStatic)
                {
                    // Check if we can swap
                    if (this.CanSwapWith(source) && source.CanSwapWith(this))
                    {
                        // Swap the slots
                        assignSuccess = source.PerformSlotSwap(this);
                    }
                }
                // If the target slot is not static
                // and the source slot is a static one
                else if (!this.isStatic && source.isStatic)
                {
                    assignSuccess = this.Assign(source);
                }
            }

            // If this slot failed to be assigned
            if (!assignSuccess)
            {
                this.OnAssignBySlotFailed(source);
            }

            // Use the event
            eventData.Use();
        }
开发者ID:DevDanSTL,项目名称:ggj2016,代码行数:64,代码来源:UISlotBase.cs

示例5: OnDrag

        /// <summary>
        /// Raises the drag event.
        /// </summary>
        /// <param name="eventData">Event data.</param>
        public virtual void OnDrag(PointerEventData eventData)
        {
            // Check if the dragging has been started
            if (this.m_DragHasBegan)
            {
                // Update the dragged object's position
                if (this.m_CurrentDraggedObject != null)
                    this.UpdateDraggedPosition(eventData);

                // Use the event
                eventData.Use();
            }
        }
开发者ID:DevDanSTL,项目名称:ggj2016,代码行数:17,代码来源:UISlotBase.cs

示例6: OnBeginDrag

        /// <summary>
        /// Raises the begin drag event.
        /// </summary>
        /// <param name="eventData">Event data.</param>
        public virtual void OnBeginDrag(PointerEventData eventData)
        {
            if (!this.enabled || !this.IsAssigned() || !this.m_DragAndDropEnabled)
            {
                eventData.Reset();
                return;
            }

            // Check if we have a key modifier and if it's held down
            if (!this.DragKeyModifierIsDown())
            {
                eventData.Reset();
                return;
            }

            // Start the drag
            this.m_DragHasBegan = true;

            // Create the temporary icon for dragging
            this.CreateTemporaryIcon(eventData);

            // Prevent event propagation
            eventData.Use();
        }
开发者ID:DevDanSTL,项目名称:ggj2016,代码行数:28,代码来源:UISlotBase.cs

示例7: OnDrop

        /// <summary>
        /// This event is fired when an item is dropped
        /// onto this slot. Will accept the item
        /// into the slot OR swap the item. If the item is
        /// `Stackable`, will attempt to stack it
        /// </summary>
        /// <param name="eventData">The `PointerEventData` of the event</param>
        public virtual void OnDrop(PointerEventData eventData)
        {
            if (eventData.used || Draggable.DraggedItem == null) {
                return;
            }

            //  if this slot doesn't have an item,
            //  add this one
            if (Item == null) {
                AddItem(Draggable.DraggedItem);
            } else {

                Stackable stackableItem = Draggable.DraggedItem.GetComponent<Items.Stackable>();
                Stackable slotStackableItem = Item.GetComponent<Items.Stackable>();

                //  the dropped item is stackable, as is
                //  the item in this slot. Attempt to stack.
                //  will return if successful.
                if (stackableItem != null && slotStackableItem != null) {
                    try {
                        slotStackableItem.Add(stackableItem);

                        Draggable.DraggedItem.OnEndDrag(eventData);
                        Draggable.DraggedItem = null;

                        //  manually spawn the tooltip as the
                        //  `OnPointerEnter` event won't trigger
                        //  automatically
                        TooltipTrigger tooltipTrigger = Item.GetComponent<TooltipTrigger>();
                        if (tooltipTrigger != null) {
                            tooltipTrigger.OnPointerEnter(
                                new PointerEventData(EventSystem.current)
                            );
                        }

                    //  if the item isn't stackable, swap items
                    } catch (NotStackableException e) {
                        Slot otherSlot = Draggable.DraggedItem.OldSlot;
                        otherSlot.AddItem(RemoveItem());
                        AddItem(Draggable.DraggedItem);

                        Draggable.DraggedItem.OnEndDrag(eventData);
                        Draggable.DraggedItem = null;
                    }
                } else {

                    //  swap the item with the item
                    //  that was dropped
                    Draggable otherItem = Draggable.DraggedItem;
                    Slot otherSlot = otherItem.OldSlot;

                    //  if other slot is currently occupied,
                    //  the draggable item will need to be
                    //  dropped before it can be swapped
                    if (otherSlot.Item != null) {
                        return;
                    }

                    //  try to swap items- will only fail
                    //  if one slot requires a specific
                    //  `ItemType`
                    try {
                        //  don't remove the item from
                        //  this slot until it successfully
                        //  gets added to the other slot
                        Draggable itemInThisSlot = Item;
                        otherSlot.AddItem(itemInThisSlot);

                        RemoveItem();
                        AddItem(otherItem);
                    } catch(CannotAddItemException e) {
                        Debug.LogWarning(e);
                        return;
                    }
                }
            }

            Item.OnEndDrag(eventData);
            eventData.Use();
        }
开发者ID:adampassey,项目名称:collect,代码行数:87,代码来源:Slot.cs

示例8: OnPointerClick

 /// <summary>
 /// When this stack is clicked, check if the
 /// user is holding down the key modifier. If
 /// so, display the `StackableSplitter` which
 /// allows the user to enter a number to
 /// remove from this stack
 /// </summary>
 /// <param name="eventData">The `PointerEventData` of the event</param>
 public void OnPointerClick(PointerEventData eventData)
 {
     if (Input.GetKey(keyModifier)) {
         StackableSplitterFactory.Create(this);
         eventData.Use();
     }
 }
开发者ID:adampassey,项目名称:collect,代码行数:15,代码来源:Stackable.cs

示例9: OnPointerClick

        public override void OnPointerClick(PointerEventData eventData)
        {
            //Debug.Log("OnPointerClick (isFocused: {0}, isUsed: {1}, isDragging: {2})".Fmt(isFocused, eventData.used, eventData.dragging));

            if (!interactable)
            {
                return;
            }

            if (eventData.dragging)
            {
                return;
            }

            EventSystem.current.SetSelectedGameObject(gameObject, eventData);

            base.OnPointerClick(eventData);

            if ((m_Keyboard == null || !m_Keyboard.active))
            {
                OnSelect(eventData);
            }
            else
            {
                UpdateLabel();
                eventData.Use();
            }
        }
开发者ID:TripleLoopGames,项目名称:space-roaches,代码行数:28,代码来源:SRNumberSpinner.cs

示例10: OnEndDrag

        public override void OnEndDrag(PointerEventData eventData)
        {
            if (!interactable)
            {
                return;
            }

            //Debug.Log("OnEndDrag (isFocused: {0}, isUsed: {1})".Fmt(isFocused, eventData.used));

            //base.OnEndDrag(eventData);

            eventData.Use();

            if (_dragStartAmount != _currentValue)
            {
                DeactivateInputField();
                SendOnSubmit();
            }
        }
开发者ID:TripleLoopGames,项目名称:space-roaches,代码行数:19,代码来源:SRNumberSpinner.cs

示例11: OnPointerClick

		public void OnPointerClick(PointerEventData eventData) {

			ExecuteEvents.Execute<IHeatmapHandler>(eventData.pointerPress, eventData, HeatmapEvents.heatmapHandler);
			eventData.Use();

		}
开发者ID:Cyberbanan,项目名称:Unity3d.UI.Windows,代码行数:6,代码来源:HeatmapInputModule.cs


注:本文中的UnityEngine.EventSystems.PointerEventData.Use方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。