In my case, I have a world-space canvas containing a tile I want to drag around inside of it:
using UnityEngine;
public class TileAction : MonoBehaviour
{
public Canvas m_canvas;
private Vector3 m_origin;
public void Select()
{
m_origin = transform.position;
Debug.Log("Selected; " + m_origin.ToString());
}
public void Drag()
{
Vector2 position;
RectTransformUtility.ScreenPointToLocalPointInRectangle(m_canvas.transform as RectTransform, Input.mousePosition, m_canvas.worldCamera, out position);
transform.position = m_canvas.transform.TransformPoint(position);
Debug.Log("Dragging;" + m_canvas.transform.TransformPoint(position).ToString());
}
public void Drop()
{
transform.position = m_origin;
Debug.Log("Dropped.");
}
}
I have an Event Trigger on this tile with Pointer Down, Pointer Up, and Drag events. It works fine, and I can drag it around the canvas.
Then I install the 0.9.6 Input System preview package, update the Event System in the scene to use the new Input System UI Input Module, and this functionality is completely broken.
What should I be doing instead?
I’m having a very hard time getting my head around the events and input systems, and I’m not sure what are the old and what are the contemporary methods nowadays.