Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        ICameraState state = _state.input(this);

        if (state == null)
        {
            _state.update(this);
        }
        else
        {
            _state = state;
            _state.entry(this);
        }


        #region
        //bool leftClicked = Input.GetMouseButtonDown(0);
        //bool rightClicked = Input.GetMouseButtonDown(1);


        //// Select an object when left clicked, and there is no currently selected object.
        //if (leftClicked && !_selectedObj && !EventSystem.current.IsPointerOverGameObject())
        //{
        //    Ray mousePos = Camera.main.ScreenPointToRay(Input.mousePosition);
        //    RaycastHit rayHit;

        //    if (Physics.Raycast(mousePos.origin, mousePos.direction, out rayHit, Mathf.Infinity))
        //    {
        //        _selectedObj = rayHit.collider.gameObject;
        //        Debug.Log("Selected: " + _selectedObj.name);
        //    }
        //}
        //// Deselect currently selected object
        //else if (rightClicked)
        //    _selectedObj = null;



        //float horizontal = Input.GetAxis("Mouse X");
        //float vertical = Input.GetAxis("Mouse Y");
        //// Move selected object with mouse
        //if (_selectedObj)
        //{
        //    float height = 0.0f;

        //    if (Input.GetMouseButton(2))
        //    {
        //        height = vertical;
        //        horizontal = 0.0f;
        //        vertical = 0.0f;
        //    }

        //    if (Input.GetMouseButton(0))
        //        _selectedObj.transform.position += new Vector3(horizontal, height, vertical);
        //}
        //// Move camera
        //else
        //{
        //    if (Input.GetMouseButton(1))
        //    {
        //        transform.position += transform.right * horizontal;
        //        transform.position += transform.up * vertical;
        //    }

        //    transform.position += transform.forward * Input.GetAxis("Mouse ScrollWheel") * 3.0f;

        //    if (Input.GetMouseButton(2))
        //    {
        //        transform.Rotate(new Vector3(2.0f * vertical, 0.0f, 0.0f));
        //        transform.Rotate(new Vector3(0.0f, 2.0f * horizontal, 0.0f));
        //    }
        //}
        #endregion
    }