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);
}
}