コード例 #1
0
    private void CheckInteraction()
    {
        Ray        forward = playerCam.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(forward, out hit, maxInteractionDistance))
        {
            InteractiveObject o = hit.collider.gameObject.GetComponent <InteractiveObject>();
            if (o != null)
            {
                o.highlighted = true;
                if (Input.GetKeyDown(KeyCode.E))
                {
                    o.DoSomething();
                }
            }
        }
    }