コード例 #1
0
    void Update()
    {
        var mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        mousePosition.z = 0;
        if (_toPlace != null)
        {
            _toPlace.transform.position = mousePosition;
            if (Input.GetMouseButtonDown(0))
            {
                if (!CoffeeMakerSpawner.WithinGrid(mousePosition))
                {
                    return;
                }



                mousePosition.z             = 0;
                mousePosition.y             = Mathf.Round(mousePosition.y);
                mousePosition.x             = Mathf.Round(mousePosition.x);
                _toPlace.transform.position = mousePosition;
                _toPlace.enabled            = true;
                _toPlace = null;
            }
        }
    }
コード例 #2
0
    void EnsureWithinGrid()
    {
        var position = _teapot.transform.position;

        _teapot.transform.position = CoffeeMakerSpawner.ForceWithinGrid(position);
    }