From e3a58966d2bbaf3f8f95f545ef3881bef4cfb5b7 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 18 Mar 2015 16:06:55 +0000 Subject: [PATCH] Setting Draggable2D drag enabled to false doesn't stop mouse up events #87 Handler methods now early out if dragEnabled is false. --- Assets/Fungus/Sprite/Scripts/Draggable2D.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Assets/Fungus/Sprite/Scripts/Draggable2D.cs b/Assets/Fungus/Sprite/Scripts/Draggable2D.cs index 8f944591..6e586b9c 100644 --- a/Assets/Fungus/Sprite/Scripts/Draggable2D.cs +++ b/Assets/Fungus/Sprite/Scripts/Draggable2D.cs @@ -60,6 +60,11 @@ namespace Fungus protected virtual void OnMouseUp() { + if (!dragEnabled) + { + return; + } + bool dragCompleted = false; DragCompleted[] handlers = GetHandlers(); @@ -92,6 +97,11 @@ namespace Fungus protected virtual void OnTriggerEnter2D(Collider2D other) { + if (!dragEnabled) + { + return; + } + foreach (DragEntered handler in GetHandlers()) { handler.OnDragEntered(this, other); @@ -105,6 +115,11 @@ namespace Fungus protected virtual void OnTriggerExit2D(Collider2D other) { + if (!dragEnabled) + { + return; + } + foreach (DragExited handler in GetHandlers()) { handler.OnDragExited(this, other);