Exemple #1
0
    public void SelectAnchorPoint()
    {
        RaycastHit hit;
        Vector3    startPosRay = Input.mousePosition;

        if (gameController.VRMode)
        {
            startPosRay.x = Screen.width / 2;
            startPosRay.y = Screen.height / 2;
        }
        if (Physics.Raycast(this.inventoryCamera.ScreenPointToRay(startPosRay), out hit))
        {
            if (hit.collider.GetComponent <AnchorPoint> ())
            {
                AnchorPoint pointedAnchor = hit.collider.GetComponent <AnchorPoint> ();
                if (this.selectedAnchor == null)
                {
                    this.selectedAnchor = pointedAnchor;
                    pointedAnchor.Select();
                    return;
                }
                if (this.selectedAnchor.Equals(pointedAnchor))
                {
                    this.selectedAnchor = null;
                    pointedAnchor.Deselect();
                    return;
                }
                //if (this.selectedAnchor.transform.parent.Equals (pointedAnchor.transform.parent)) {
                if (this.selectedAnchor.GetComponentInParent <RotateByDragging>().Equals(pointedAnchor.GetComponentInParent <RotateByDragging>()))
                {
                    this.selectedAnchor.Deselect();
                    this.selectedAnchor = pointedAnchor;
                    pointedAnchor.Select();
                    return;
                }
                this.ConnectAnchors(pointedAnchor);
            }
        }
    }