示例#1
0
    protected virtual void GetTower()
    {
        //transfer the mouse position to the world position
        Vector3 screenPoint  = Camera.main.WorldToScreenPoint(transform.position);
        Vector3 startDragPos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
        //spawn the selected tower
        GameObject tower = Instantiate(towers[selectedTower], startDragPos, transform.rotation) as GameObject;

        //set the right start properties of the tower, so it knows its being dragged.

        mouse.SetTarget = tower;
        Drag drag = tower.GetComponent <Drag>();

        drag.StartDrag();
        drag.SetKinematic = false;
    }