- Home /
 
               Question by 
               Tilk · May 06, 2012 at 02:19 PM · 
                guimousegui.window  
              
 
              Mouse trailing
When I drag GUI elements with my mouse they trail after it by one frame, they don't move instantly after it. Tell me please how to fix it.
I tried to use the standard GUI.Window element, I even tried to write my own, counting mouseDelta like this:
     void Update ()
     {
             MouseDeltaX = Input.mousePosition.x - OldMouseX;
             MouseDeltaY = Input.mousePosition.y - OldMouseY;
             
             if(Input.GetMouseButtonDown(0))
             {
                     isLeftButtonDown = true;
             }
             if(Input.GetMouseButtonUp(0))
             {
                     isLeftButtonDown = false;
             }
             
             if(isLeftButtonDown)
             {
                     StatsWindow.SetPos(StatsWindow.xpos + MouseDeltaX, StatsWindow.ypos - MouseDeltaY);
             }
     
             OldMouseX=Input.mousePosition.x;
             OldMouseY=Input.mousePosition.y;
     }
     
     void OnGUI()
     {
         StatsWindow.Display();
     }
               Comment
              
 
               
              I'm not sure if this will help, but you are constantly setting the isLeftButtonDown = true. I would modify the statement to this:
if(Input.Get$$anonymous$$ouseButtonDown(0) && isLeftButtonDown != true)
and then do the same, but with false for the other statement.
Your answer
 
 
             Follow this Question
Related Questions
Clickable GUI.Window 1 Answer
detect mouseover with grid buttons? 1 Answer
Ensuring Correct Call Order 0 Answers
Setting the mouse position to specific coordinates 5 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                