Пример #1
0
    void TouchEventUpdate()
    {
        if (Input.GetMouseButton(0))
        {
            // UI 체크
            hit2D = Physics2D.Raycast(ScreenToWorldPoint(), Vector2.zero);
            if (curSelect_State == Select_State.NONE_SELECT && hit2D.collider != null)
            {
                //Debug.Log("UI : " + hit2D.transform.name);
                curSelect       = hit2D.transform.GetComponent <ITouchable>();
                curSelect_State = Select_State.ENTER;

                if (curSelect.IsUI)
                {
                    curSelect.TouchEnter(ScreenToWorldPoint());
                    curSelect_State = Select_State.STAY;
                    return;
                }
                else
                {
                    curSelect       = null;
                    curSelect_State = Select_State.NONE_SELECT;
                }
            }
            else if (curSelect_State == Select_State.STAY)
            {
                curSelect.TouchStay(ScreenToWorldPoint());
                return;
            }


            // 오브젝트 체크
            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit3D))
            {
                Debug.Log("Object : " + hit3D.transform.name);
                curSelect = hit3D.transform.GetComponent <ITouchable>();
                if (!curSelect.IsUI)
                {
                    curSelect.TouchEnter(ScreenToWorldPoint());
                    curSelect_State = Select_State.STAY;
                    return;
                }
                else
                {
                    curSelect       = null;
                    curSelect_State = Select_State.NONE_SELECT;
                }
            }
            else if (curSelect_State == Select_State.STAY)
            {
                curSelect.TouchStay(ScreenToWorldPoint());
                return;
            }
        }
        else
        {
            if (curSelect_State == Select_State.STAY)
            {
                curSelect.TouchExit(Input.mousePosition);
                curSelect       = null;
                curSelect_State = Select_State.NONE_SELECT;
            }
        }
    }