Event.current.delta problem with Y-axis

Hi, I have a simple editor script to move the object relative to the mouse. It works in the x-axis but the y-axis does not work, I do not know why. The Y axis have very high values. Please help.

void OnSceneGUI()
{
Event e = Event.current;

Vector3 guiDelta = new Vector3(e.delta.x, Camera.current.pixelHeight - e.delta.y, 0f);

Vector3 screenDelta = GUIUtility.GUIToScreenPoint(guiDelta);

Ray worldRay = Camera.current.ScreenPointToRay(screenDelta);

Vector3 worldDelta = worldRay.GetPoint(0);
worldDelta -= Camera.current.ScreenPointToRay(Vector3.zero).GetPoint(0);

HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));

if (e.type == EventType.MouseDrag)
{
test.transform.position += new Vector3(worldDelta.x, worldDelta.y, 0);
}
}

Hi,
Sorry if i misunderstood your question.I don’t have the solution for your query but I have a alternate method. If you are using like you have to move an Image as the same as you are moving your pointer/mouse/finger.
Can you spriterenderer instead of the canvas ??? Because it is easy to operate transform instead of the rectTransform

‘I can also proveide the code if needed to move any image follow the pointer’

Basically I’m doing my own terrain editor in 2D and I want to move the vertices with a virtual brush, something like this:

http://gfycat.com/DeficientDecimalBullmastiff

:eyes:
Sorry unaware about this :frowning:
great work :slight_smile: