Пример #1
0
    private void UpdateVirtualInput()
    {
        if (EventSystem.current.IsPointerOverGameObject() || EventSystem.current.IsPointerOverGameObject(0))
        {
            return;
        }

        switch (TouchUtility.GetTouch())
        {
        case TouchInfo.Began:     //タッチ初めにスクリーン上の位置を記憶
            touchStartPos  = TouchUtility.GetTouchPosition();
            touchingScreen = true;
            uiManager.SetActiveVirtualPad(true);
            uiManager.UpdateMovavbleAreaImage(touchStartPos);
            break;

        case TouchInfo.Moved:     //タッチ中にスクリーン上の位置を記憶①
            touchCurrentPos = TouchUtility.GetTouchPosition();
            uiManager.UpdateCurrentTouchPosImage(touchCurrentPos);
            break;

        case TouchInfo.Stationary:     //タッチ中にスクリーン上の位置を記憶②
            touchCurrentPos = TouchUtility.GetTouchPosition();
            uiManager.UpdateCurrentTouchPosImage(touchCurrentPos);
            break;

        case TouchInfo.Ended:     //タッチ終了後にタッチ位置をリセット
            touchStartPos   = Vector2.zero;
            touchCurrentPos = Vector2.zero;
            touchingScreen  = false;
            uiManager.SetActiveVirtualPad(false);
            break;
        }
    }
Пример #2
0
    private Vector3 GetChopStickPos(int fingerId)
    {
        Vector3    pos = Vector3.zero;
        Ray        ray = Camera.main.ScreenPointToRay(TouchUtility.GetTouchPosition(fingerId));
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 1 << LayerMask.NameToLayer(GameSystemManager.ChopstickMovableLayer)))
        {
            pos.x = hit.point.x;
            pos.z = hit.point.z;
        }

        return(pos);
    }