Detects drag and drop interactions on a Game Object, and sends events to all Flowchart event handlers in the scene. The Game Object must have Collider2D & RigidBody components attached. The Collider2D must have the Is Trigger property set to true. The RigidBody would typically have the Is Kinematic property set to true, unless you want the object to move around using physics. Use in conjunction with the Drag Started, Drag Completed, Drag Cancelled, Drag Entered & Drag Exited event handlers.
Inheritance: UnityEngine.MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerEnterHandler, IPointerExitHandler
Example #1
0
 public virtual void OnDragStarted(Draggable2D draggableObject)
 {
     if (draggableObject == this.draggableObject)
     {
         ExecuteSequence();
     }
 }
Example #2
0
 public virtual void OnDragCancelled(Draggable2D draggableObject)
 {
     if (draggableObject == this.draggableObject)
     {
         ExecuteBlock();
     }
 }
		public virtual void OnDragCancelled(Draggable2D draggableObject)
		{
			if (draggableObject == this.draggableObject)
			{
				ExecuteBlock();
			}
		}
 /// <summary>
 /// Called by the Draggable2D object when the the drag enters the drag target.
 /// </summary>
 public virtual void OnDragEntered(Draggable2D draggableObject, Collider2D targetObject)
 {
     if (draggableObject == this.draggableObject &&
         targetObject == this.targetObject)
     {
         ExecuteBlock();
     }
 }
Example #5
0
 public virtual void OnDragExited(Draggable2D draggableObject, Collider2D targetObject)
 {
     if (draggableObject == this.draggableObject &&
         targetObject == this.targetObject)
     {
         ExecuteSequence();
     }
 }
Example #6
0
 /// <summary>
 /// Called by the Draggable2D object when the the drag enters the drag target.
 /// </summary>
 public virtual void OnDragEntered(Draggable2D draggableObject, Collider2D targetObject)
 {
     if (draggableObject == this.draggableObject &&
         targetObject == this.targetObject)
     {
         ExecuteBlock();
     }
 }
 /// <summary>
 /// Called by the Draggable2D object when the it exits the drag target.
 /// </summary>
 public virtual void OnDragExited(Draggable2D draggableObject, Collider2D targetObject)
 {
     if (this.targetObject != null &&
         draggableObject == this.draggableObject &&
         targetObject == this.targetObject)
     {
         overTarget = false;
     }
 }
Example #8
0
 /// <summary>
 /// Called by the Draggable2D object when the it exits the drag target.
 /// </summary>
 public virtual void OnDragExited(Draggable2D draggableObject, Collider2D targetObject)
 {
     if (this.targetObject != null &&
         draggableObject == this.draggableObject &&
         targetObject == this.targetObject)
     {
         overTarget = false;
     }
 }
 /// <summary>
 /// Called by the Draggable2D object when the it exits the drag target.
 /// </summary>
 public virtual void OnDragExited(Draggable2D draggableObject, Collider2D targetObject)
 {
     if (this.targetObjects != null && this.draggableObjects != null &&
         this.draggableObjects.Contains(draggableObject) &&
         this.targetObjects.Contains(targetObject))
     {
         overTarget     = false;
         targetCollider = null;
     }
 }
Example #10
0
 public virtual void OnDragCancelled(Draggable2D draggableObject)
 {
     if (draggableObjects.Contains(draggableObject))
     {
         if (draggableRef != null)
         {
             draggableRef.Value = draggableObject.gameObject;
         }
         ExecuteBlock();
     }
 }
Example #11
0
 /// <summary>
 /// Called by the Draggable2D object when the it enters the drag target.
 /// </summary>
 public virtual void OnDragEntered(Draggable2D draggableObject, Collider2D targetObject)
 {
     if (draggableObject.BeingDragged &&
         this.targetObjects != null && this.draggableObjects != null &&
         this.draggableObjects.Contains(draggableObject) &&
         this.targetObjects.Contains(targetObject))
     {
         overTarget     = true;
         targetCollider = targetObject;
     }
 }
Example #12
0
 void ISerializationCallbackReceiver.OnAfterDeserialize()
 {
     //add any dragableobject already present to list for backwards compatability
     if (draggableObject != null)
     {
         if (!draggableObjects.Contains(draggableObject))
         {
             draggableObjects.Add(draggableObject);
         }
         draggableObject = null;
     }
 }
Example #13
0
        /// <summary>
        /// Called by the Draggable2D object when the the drag ends over the drag target.
        /// </summary>
        public virtual void OnDragCompleted(Draggable2D draggableObject)
        {
            if (draggableObject == this.draggableObject &&
                overTarget)
            {
                // Assume that the player will have to do perform another drag and drop operation
                // to complete the drag again. This is necessary because we don't get an OnDragExited if the
                // draggable object is set to be inactive.
                overTarget = false;

                ExecuteBlock();
            }
        }
 /// <summary>
 /// Called by the Draggable2D object when the the drag ends over the drag target.
 /// </summary>
 public virtual void OnDragCompleted(Draggable2D draggableObject)
 {
     if (draggableObject == this.draggableObject &&
         overTarget)
     {
         // Assume that the player will have to do perform another drag and drop operation
         // to complete the drag again. This is necessary because we don't get an OnDragExited if the
         // draggable object is set to be inactive.
         overTarget = false;
         
         ExecuteBlock();
     }
 }
Example #15
0
 /// <summary>
 /// Called by the Draggable2D object when the the drag enters the drag target.
 /// </summary>
 public virtual void OnDragEntered(Draggable2D draggableObject, Collider2D targetObject)
 {
     if (this.targetObjects != null && this.draggableObjects != null &&
         this.draggableObjects.Contains(draggableObject) &&
         this.targetObjects.Contains(targetObject))
     {
         if (draggableRef != null)
         {
             draggableRef.Value = draggableObject.gameObject;
         }
         if (targetRef != null)
         {
             targetRef.Value = targetObject.gameObject;
         }
         ExecuteBlock();
     }
 }
        private void Awake()
        {
            //add any dragableobject already present to list for backwards compatability
            if (draggableObject != null)
            {
                if (!draggableObjects.Contains(draggableObject))
                {
                    draggableObjects.Add(draggableObject);
                }
            }

            if (targetObject != null)
            {
                if (!targetObjects.Contains(targetObject))
                {
                    targetObjects.Add(targetObject);
                }
            }
            draggableObject = null;
            targetObject    = null;
        }
        /// <summary>
        /// Called by the Draggable2D object when the the drag ends over the drag target.
        /// </summary>
        public virtual void OnDragCompleted(Draggable2D draggableObject)
        {
            if (this.draggableObjects.Contains(draggableObject) &&
                overTarget)
            {
                // Assume that the player will have to do perform another drag and drop operation
                // to complete the drag again. This is necessary because we don't get an OnDragExited if the
                // draggable object is set to be inactive.
                if (draggableRef != null)
                {
                    draggableRef.Value = draggableObject.gameObject;
                }
                if (targetRef != null)
                {
                    targetRef.Value = targetCollider.gameObject;
                }

                overTarget     = false;
                targetCollider = null;

                ExecuteBlock();
            }
        }
Example #18
0
 public DragStartedEvent(Draggable2D draggableObject)
 {
     DraggableObject = draggableObject;
 }
Example #19
0
 public DragEnteredEvent(Draggable2D draggableObject, Collider2D targetCollider)
 {
     DraggableObject = draggableObject;
     TargetCollider = targetCollider;
 }
Example #20
0
 public DragCompletedEvent(Draggable2D draggableObject)
 {
     DraggableObject = draggableObject;
 }
 public DragCompletedEvent(Draggable2D draggableObject)
 {
     DraggableObject = draggableObject;
 }
Example #22
0
 public DragCancelledEvent(Draggable2D draggableObject)
 {
     DraggableObject = draggableObject;
 }
Example #23
0
 public DragStartedEvent(Draggable2D draggableObject)
 {
     DraggableObject = draggableObject;
 }
Example #24
0
 public DragCancelledEvent(Draggable2D draggableObject)
 {
     DraggableObject = draggableObject;
 }
Example #25
0
 public DragExitedEvent(Draggable2D draggableObject, Collider2D targetCollider)
 {
     DraggableObject = draggableObject;
     TargetCollider  = targetCollider;
 }