예제 #1
0
    void PartSelection()
    {
        if (Input.GetMouseButtonUp(0) == true && attachingMode == false)
        {
            ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out rayCastHit) == true)
            {
                if (rayCastHit.collider.gameObject.GetComponent <ShipPart>() != null)
                {
                    focusedPart = rayCastHit.collider.gameObject.GetComponent <ShipPart>();
                    focusedPart.select();
                    attachingMode = true;
                }
            }
        }

        if (focusedPart != null && focusedPart.IsSelected() == true)
        {
            focusedPart.transform.position = (Vector2)(Camera.main.ScreenToWorldPoint(Input.mousePosition));

            if (Input.GetMouseButtonUp(1) == true)
            {
                focusedPart.deselect();
                attachingMode = false;
            }
        }
    }