zoukankan      html  css  js  c++  java
  • Unity3D判断鼠标向右或向左滑动,响应不同的事件

    private var first = Vector2.zero;   
    
    private var second = Vector2.zero;   
    
    function Update ()
    
    {
    
    }   
    
    function OnGUI ()
    
    {
    
        if(Event.current.type == EventType.MouseDown)
    
      {
    
        //记录鼠标按下的位置   
    
         first = Event.current.mousePosition ;
    
        }   
    
       if(Event.current.type == EventType.MouseDrag)
    
      {
    
        //记录鼠标拖动的位置   
    
        second = Event.current.mousePosition ;   
    
        if(second.x<first.x)
    
        {
    
          //拖动的位置的x坐标比按下的位置的x坐标小时,响应向左事件   
    
           print("left");   
    
         }   
    
         if(second.x>first.x)
    
        {
    
          //拖动的位置的x坐标比按下的位置的x坐标大时,响应向右事件   
    
           print("right");   
    
         }   
    
         first = second;   
    
      }   
    
    }
  • 相关阅读:
    Leetcode 532.数组中的K-diff数对
    Leetcode 529.扫雷游戏
    定增游戏(三)
    套利不归路(五)
    定增游戏(一)
    套利不归路(四)
    套利不归路(三)
    套利不归路(二)
    套利不归路(一)
    减持大逃亡(二)
  • 原文地址:https://www.cnblogs.com/123ing/p/3915323.html
Copyright © 2011-2022 走看看