Exemple #1
0
    void Push_TouchEvent()
    {
        //DebugWide.Log(Input.touchCount);

        if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
        {
            if (Input.touchCount > 0)
            {
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    //DebugWide.LogError("Update : TouchPhase.Began"); //chamto test
                    Init_PrevTouchMovedPos();
                    m_TouchedObject = SendMessage_TouchObject("TouchBegan", Input.GetTouch(0).position);
                }
                else if (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(0).phase == TouchPhase.Stationary)
                {
                    //DebugWide.LogError("Update : TouchPhase.Moved"); //chamto test

                    if (null != m_TouchedObject)
                    {
                        m_TouchedObject.SendMessage("TouchMoved", 0, SendMessageOptions.DontRequireReceiver);
                    }

                    Update_PrevTouchMovedPos();
                }
                else if (Input.GetTouch(0).phase == TouchPhase.Ended)
                {
                    //DebugWide.LogError("Update : TouchPhase.Ended"); //chamto test
                    //checkInput("TouchEnded",Input.GetTouch(0).position);
                    if (null != m_TouchedObject)
                    {
                        m_TouchedObject.SendMessage("TouchEnded", 0, SendMessageOptions.DontRequireReceiver);
                    }
                    m_TouchedObject = null;
                }
                else
                {
                    DebugWide.LogError("Update : Exception Input Event : " + Input.GetTouch(0).phase);
                }
            }
        }
        else if (Application.platform == RuntimePlatform.OSXEditor)
        {
            //Debug.Log("mousedown:" +Input.GetMouseButtonDown(0)+ "  mouseup:" + Input.GetMouseButtonUp(0) + " state:" +Input.GetMouseButton(0)); //chamto test
            if (Input.GetMouseButtonDown(0))
            {
                //Debug.Log ("______________ MouseBottonDown ______________" + m_TouchedObject); //chamto test

                //if(0 == (m_prevMousePosition - Input.mousePosition).sqrMagnitude)
                {                       //mouse Down
                    if (false == f_isEditorDraging)
                    {
                        //Init_PrevTouchMovedPos();
                        m_TouchedObject = SendMessage_TouchObject("TouchBegan", Input.mousePosition);
                        if (null != m_TouchedObject)
                        {
                            f_isEditorDraging = true;
                        }
                    }
                }

                //DebugWide.Log("--------------"); //chamto test
            }

            if (Input.GetMouseButtonUp(0))
            {                   //mouse Up
                                //Debug.Log ("______________ MouseButtonUp ______________" + m_TouchedObject); //chamto test
                f_isEditorDraging = false;

                if (null != m_TouchedObject)
                {
                    m_TouchedObject.SendMessage("TouchEnded", 0, SendMessageOptions.DontRequireReceiver);
                }
                m_TouchedObject = null;
                //checkInput("TouchEnded",Input.mousePosition);
            }

            //else
            if (Input_Unity.GetMouseButtonMove(0))
            {                   //mouse Move
                if (f_isEditorDraging)
                {               ///mouse Down + Move (Drag)
                    //Debug.Log ("______________ MouseMoved ______________" + m_TouchedObject); //chamto test

                    if (null != m_TouchedObject)
                    {
                        m_TouchedObject.SendMessage("TouchMoved", 0, SendMessageOptions.DontRequireReceiver);
                    }

                    //Update_PrevTouchMovedPos();
                }        //if
            }            //if

            //m_prevMousePosition = Input.mousePosition;
        }
    }
Exemple #2
0
    public static TouchPhase GetTouchEvent()
    {
        if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
        {
            if (Input.touchCount > 0)
            {
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    DebugWide.LogWhite("Update : TouchPhase.Began");                      //chamto test
                    return(TouchPhase.Began);
                }
                else if (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(0).phase == TouchPhase.Stationary)
                {
                    DebugWide.LogWhite("Update : TouchPhase.Moved");                      //chamto test
                    return(TouchPhase.Moved);
                }
                else if (Input.GetTouch(0).phase == TouchPhase.Ended)
                {
                    DebugWide.LogWhite("Update : TouchPhase.Ended");                      //chamto test
                    return(TouchPhase.Ended);
                }
                else
                {
                    DebugWide.LogWhite("Update : Exception Input Event : " + Input.GetTouch(0).phase);
                    return(Input.GetTouch(0).phase);
                }
            }
        }
        else if (Application.platform == RuntimePlatform.OSXEditor)
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (false == f_isEditorDraging)
                {
                    //DebugWide.LogWhite ("______________ MouseButtonDown ______________"); //chamto test

                    f_isEditorDraging = true;

                    return(TouchPhase.Began);
                }
            }

            if (Input.GetMouseButtonUp(0))                      //mouse Up

            //DebugWide.LogWhite ("______________ MouseButtonUp ______________"); //chamto test
            {
                f_isEditorDraging = false;

                return(TouchPhase.Ended);
            }

            //else
            if (Input_Unity.GetMouseButtonMove(0))                      //mouse Move

            {
                if (f_isEditorDraging)                          ///mouse Down + Move (Drag)

                //DebugWide.LogWhite ("______________ MouseMoved ______________"); //chamto test

                {
                    return(TouchPhase.Moved);
                }        //if
            }            //if
        }
        return(TouchPhase.Canceled);
    }