Hi guys,
in the internet i looked very long for a solution for holding an UI-Button with finger/mouse, move it there where my finger while holding is and to stay there where i left my finger from the display but i do not found any solution.
Sorry for my English.
Thanks for help!!!
using UnityEngine;
using UnityEngine.EventSystems;
public class PrefabTest : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
public bool canMove = false;
void Update()
{
if (!canMove)
return;
gameObject.transform.position = Input.mousePosition;
Debug.Log("Dragg");
}
public void OnPointerDown(PointerEventData eventData)
{
Debug.Log("Down");
canMove = true;
}
public void OnPointerUp(PointerEventData eventData)
{
Debug.Log("Up");
canMove = false;
}
}