예제 #1
0
        public void ReturnWithAnimation()
        {
            // Animate
            BetweenGlobalPosition between = gameObject.AddComponent <BetweenGlobalPosition>();

            between.Duration = 0.3f;
            between.From     = TransformCache.position;
            between.To       = LastPosition;
            between.OnFinish.AddListener(() =>
            {
                // Destroy animation component
                Destroy(between);
            });

            between.Play(true);
        }
예제 #2
0
        public void DestroyWithAnimation()
        {
            // Animate
            BetweenGlobalPosition between = gameObject.AddComponent <BetweenGlobalPosition>();

            between.Duration = 0.3f;
            between.From     = TransformCache.position;
            between.To       = LastPosition;
            between.OnFinish.AddListener(() =>
            {
                if (lastDropObject != null)
                {
                    lastDropObject.isEmpty = true;
                }
                // Destroy game object
                Destroy(gameObject);
            });

            between.Play(true);
        }
예제 #3
0
        // Attached to DragAndDrop End Drag event. When new place is invalid return to last place.
        public void OnInvalidPlaceReturn()
        {
            if (this.dragAndDrop.HoveredDropObject == null)
            {
                return;
            }

            if (!this.dragAndDrop.HoveredDropObject.isEmpty)
            {
                BetweenGlobalPosition tweenPosition = this.dragAndDrop.SelectedDragElement.GetComponent <BetweenGlobalPosition>();
                tweenPosition.To   = this.dragAndDrop.SelectedDragElement.TransformCache.position;
                tweenPosition.From = this.dragAndDrop.SelectedDragElement.LastPosition;
                tweenPosition.ResetToEnd();
                tweenPosition.OnFinish.AddListener(() =>
                {
                    tweenPosition.OnFinish.RemoveAllListeners();
                });

                tweenPosition.PlayReverse();
            }
        }