using UnityEngine;
using System.Collections;
public class Dragger : MonoBehaviour {
private bool dragged = false;
private EventDelegate evi;
private void Start()
{
evi
= new EventDelegate
(this,
"TurnOffDragged"); evi.oneShot = true;
}
private void OnDrag()
{
if(UICamera.currentTouch.pos.x > 300)
{
TweenButtonDelete();
}
if(UICamera.currentTouch.pos.x < 100)
{
TweenButtonBack();
}
}
private void OnClick()
{
if(dragged)
{
UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
TweenButtonBack();
}
else
{
UICamera.currentTouch.clickNotification = UICamera.ClickNotification.Always;
Debug.Log ("Click!");
}
}
private void TweenButtonDelete()
{
TweenPosition
.Begin(gameObject, 0
.1f,
new Vector3
(85, transform
.localPosition.y, transform
.localPosition.z)); dragged = true;
}
private void TweenButtonBack()
{
TweenPosition
.Begin(gameObject, 0
.1f,
new Vector3
(0, transform
.localPosition.y, transform
.localPosition.z)).onFinished.Add(evi
); }
private void TurnOffDragged()
{
dragged = false;
}
}