Exemple #1
0
    void GetInput()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        Debug.DrawRay(ray.origin, ray.direction * 1000);
        Physics.Raycast(ray, out hit);
        if (hit.transform != null)
        {
            if (hit.transform.GetComponent <Interactible>())
            {
                Interactible interactible = hit.transform.GetComponent <Interactible>();
                if (Input.GetMouseButtonDown(0))
                {
                    interactible.LeftClickSelect();
                    //Debug.Log(hit.transform.name + " clicked");
                }
                else if (Input.GetMouseButtonDown(1))
                {
                    interactible.RightClickSelect();
                }
                else if (Input.GetMouseButtonUp(0))
                {
                    if (interactible.LeftClicked)
                    {
                        interactible.LeftClickDeselect();
                    }
                    //Debug.Log(hit.transform.name + " released");
                }
                else if (Input.GetMouseButtonUp(1))
                {
                    if (interactible.RightClicked)
                    {
                        interactible.RightClickDeselect();
                    }
                }
            }
        }
    }