- Home /
Delta event out of Editor Problem
Hi,im using Event.Current.delta to move a texture arround the screen. The problem comes when i build the scene. Current delta goes crazy and doesnt stop never.
If i stop moving the mouse texture keeps mooving on the last direction.
Thanks
Answer by David · Jan 18, 2010 at 02:24 PM
I go crazy using Delta to drag objetcs so i change textures my planes and now i have it done. The problem should be that delta coult be used out of Unity editor because on editor all works well.
Answer by Bampf · Jan 17, 2010 at 05:56 PM
We may need to see some code to answer this one. But my first guess would be that you are not checking the Event.type field. I think that your code in OnGUI is getting called at fixed intervals (to draw GUI elements, perhaps) and you are treating each one as if the mouse had moved. If so, try limiting your code to Event.type==EventType.MouseMove. But, you will need to draw your texture regardless- the question is whether to draw it at the same location as last time, or whether to move it to a new location.
Is this texture supposed to be acting like a mouse cursor? If so, you may not need the delta at all, just read the Input mousePosition, as described in: this answer.
This answer is bunk. The Event.current.delta values when the project is compiled are exactly the same as Event.mousePosition, it doesn't matter if you're checking the event type or not (I'm checking for $$anonymous$$ouseDrag events, specifically, and still see this issue).
Data gleaned from this thread: http://forum.unity3d.com/threads/63404-Event.delta-problem-of-Unity3
Answer by CgShady · Nov 23, 2011 at 08:29 PM
Let me add to this. It works "out of the editor" on MacOSX platform, but not on Windows. My experience is the exact same as described above, I'm using the delta on a MouseDrag event, so I am checking the event type, and I'm using it to let the user zoom with a mouse drag with the right mouse button.
It works in both MacOSX and Windows versions of the editor, it works in the OSX compiled app. It just doesn't in the executable version on windows. I did some printing on the screen and can confirm that Event.current.delta == Event.mousePosition, but again only on windows compiled project. I tried to make my own mechanism to compute delta, storing previous value, etc.. And guess what, it works in the editor, but not in the compiled version. I feel there's some deeper bug on the event mechanism on windows builds.
Answer by CgShady · Nov 24, 2011 at 09:32 AM
All, I just found a workaround. I was using Event.current.delta.y to zoom in and out with the right mouse button.
As it doesn't work on Windows builds, I am now using Input.GetAxis("Mouse Y"). That works OK, I simply had to changed the sensitivity, as this one isn't given as a pixel delta, but seems to be using the mouse Dpi and speed settings.
Here's the code for reference :
if (Event.current.type == EventType.MouseDrag && Event.current.button == 1)
{
// Camera.main.fieldOfView += Event.current.delta.y/10;
Camera.main.fieldOfView += Input.GetAxis("Mouse Y");
}
Hope this helps !
Your answer
Follow this Question
Related Questions
Temporary textures or Materials in Editor removed in build 1 Answer
Serious Rendering Issue - editor vs build 3 Answers
How to draw a small circle on scene and moving it wherever mouse cursor moves 2 Answers
Distribute terrain in zones 3 Answers
Assign texture to shader bypassing material (in Unity Editor) 1 Answer