Exemplo n.º 1
0
    //private

    private BridgeBeam CreateBeam(GameObject snapPoint)
    {
        GameObject go = Instantiate(BridgeBeamPrefab, snapPoint.transform.position, new Quaternion()) as GameObject;
        BridgeBeam bb = go.GetComponent <BridgeBeam>();

        bb.bridgeSetupParent = this;
        Vector3 newPos = new Vector3(snapPoint.transform.position.x, snapPoint.transform.position.y, gridOrigin.z);

        bb.StartLayout(newPos, snapPoint, this);
        bb.transform.parent = bridgeBeams.transform;

        return(bb);
    }
Exemplo n.º 2
0
    private void DestroyBeam(GameObject snapPoint)
    {
        if (null != snapPoint)
        {
            BridgeBeam bb = snapPoint.GetComponent <SnapPoint> ().bridgeBeamParent;

            if (bb != null)
            {
                Destroy(bb.gameObject);
            }
        }
        else
        {
            Ray        r  = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit rh = new RaycastHit();

            if (Physics.Raycast(r, out rh, Mathf.Infinity, 1 << 9 | 1 << 10))
            {
                Destroy(rh.collider.transform.parent.gameObject);
            }
        }
    }