Example #1
0
    private void Update()
    {
        Ray        camRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        // Select
        if (Physics.Raycast(camRay, out hit))
        {
            IK ik = hit.collider.GetComponent <IK>();
            if (ik)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    selected = ik;
                    selected.Select();
                }
            }
        }


        // Move
        if (selected)
        {
            if (Physics.Raycast(camRay, out hit))
            {
                selected.Move(hit.point);
            }

            // Release
            if (Input.GetMouseButtonUp(0))
            {
                selected.Release();
                selected = null;
            }
        }
    }