コード例 #1
0
ファイル: CursorObject.cs プロジェクト: wangqinru/licht
    // Update is called once per frame
    void Update()
    {
        int cx = nowNumber % Standard[0][0];
        int cy = nowNumber / Standard[0][0];

        int old = nowNumber;

        float tx = cursorTexture.pixelInset.x;
        float ty = cursorTexture.pixelInset.y;

        if (inputManger.StickLR == 1 && cx < Standard[0][0] - 1 && nowNumber + 1 < total)
        {
            nowNumber++;
            tx += Standard[0][1];
        }

        if (inputManger.StickLR == -1 && cx > 0)
        {
            nowNumber--;
            tx -= Standard[0][1];
        }

        if (inputManger.StickUD == 1 && cy < Standard[1][0] - 1 && nowNumber + Standard[0][0] < total)
        {
            nowNumber += Standard[0][0];
            ty        += Standard[1][1];
        }

        if (inputManger.StickUD == -1 && cy > 0)
        {
            nowNumber -= Standard[0][0];
            ty        -= Standard[1][1];
        }

        if (inputManger.DecisionButton == 1)
        {
            CallButtonEvent callButtonEvent = new CallButtonEvent(menu.ButtonEvent);
            callButtonEvent(nowNumber);
        }

        if (inputManger.CancelButton == 1)
        {
            menu.CancelEvent();
        }

        ChangeCategory();

        if (old != nowNumber)
        {
            cursorTexture.pixelInset = new Rect(tx, ty, cursorTexture.pixelInset.width, cursorTexture.pixelInset.height);
            menu.ButtonOver();
        }
    }