From ce0f9e2daa1f1d8edb230a7de8db103c6b3c9e3f Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Thu, 13 Aug 2015 15:10:00 +0100 Subject: [PATCH] Fixed: Draggable objects don't return to start pos if drag completes #130 --- Assets/Fungus/Sprite/Scripts/Draggable2D.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Assets/Fungus/Sprite/Scripts/Draggable2D.cs b/Assets/Fungus/Sprite/Scripts/Draggable2D.cs index 73c9697b..6d88c58b 100644 --- a/Assets/Fungus/Sprite/Scripts/Draggable2D.cs +++ b/Assets/Fungus/Sprite/Scripts/Draggable2D.cs @@ -1,5 +1,6 @@ using UnityEngine; using System.Collections; +using UnityEngine.Serialization; namespace Fungus { @@ -16,8 +17,12 @@ namespace Fungus [Tooltip("Is object dragging enabled")] public bool dragEnabled = true; - [Tooltip("Move object back to its starting position when drag is released")] - public bool returnToStartPos = true; + [Tooltip("Move object back to its starting position when drag is cancelled")] + [FormerlySerializedAs("returnToStartPos")] + public bool returnOnCancelled = true; + + [Tooltip("Move object back to its starting position when drag is completed")] + public bool returnOnCompleted = true; [Tooltip("Time object takes to return to its starting position")] public float returnDuration = 1f; @@ -84,6 +89,11 @@ namespace Fungus { handler.OnDragCompleted(this); dragCompleted = true; + + if (returnOnCompleted) + { + iTween.MoveTo(gameObject, startingPosition, returnDuration); + } } } } @@ -95,7 +105,7 @@ namespace Fungus handler.OnDragCancelled(this); } - if (returnToStartPos) + if (returnOnCancelled) { iTween.MoveTo(gameObject, startingPosition, returnDuration); }