コード例 #1
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            menuOpen = !menuOpen;
            if (menuOpen)
            {
                Cursor.lockState = CursorLockMode.None;
            }
            else
            {
                Cursor.lockState = CursorLockMode.Locked;
            }
        }
        else
        {
            if (camera.transform.rotation != lastRotation || camera.transform.position != lastPos)
            {
                rayBase      = camera.ScreenPointToRay(Input.mousePosition);
                lastRotation = camera.transform.rotation;
                lastPos      = camera.transform.position;
                //
                if (Physics.Raycast(rayBase, out rayHit, 100))
                {
                }
            }
            for (int i = 1; i < 10; ++i)
            {
                if (Input.GetKeyDown("" + i))
                {
                    userBlueprint.ChangeMaterial(i - 1);
                }
            }

            if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                userBlueprint.ChangeDirection();
            }
            if (Input.GetKeyUp(KeyCode.LeftShift))
            {
                userBlueprint.ChangeDirection();
            }
            if (Input.GetKeyDown(KeyCode.E))
            {
                userBlueprint.ChangeMode();
            }

            //here
            userBlueprint.BlueprintSelect(rayHit, structure, Input.GetAxis("Mouse ScrollWheel"));
            if (Input.GetMouseButtonDown(0))
            {
                if (userBlueprint.GetLength() != 0)
                {
                    userBlueprint.ResetLength();
                }
                else if (rayHit.transform.gameObject == structure)
                {
                    buildStructure.RemovePart(rayHit);
                }
            }

            if (Input.GetMouseButtonDown(1))
            {
                userBlueprint.FirstSelection();
            }
            if (Input.GetMouseButtonUp(1))
            {
                userBlueprint.SecondSelection();
            }
        }
    }