Exemplo n.º 1
0
    void drawRoad(Road road)
    {
        int  width = road.width;
        node node1 = myNode[road.node1 - 1];
        node node2 = myNode[road.node2 - 1];

        if (node1.xPos == node2.xPos)
        {
            GameObject road1 = Instantiate(line1);
            GameObject road2 = Instantiate(line2);
            myLine1 = road1.GetComponent <line>();
            myLine2 = road2.GetComponent <line>();
            Vector3[] forNode1 = NodeToVec(node1, true, (float)width);
            Vector3[] forNode2 = NodeToVec(node2, true, (float)width);
            myLine1.DrawLine(forNode1[0], forNode2[0]);
            myLine2.DrawLine(forNode1[1], forNode2[1]);
        }

        else
        {
            GameObject road1 = Instantiate(line1);
            GameObject road2 = Instantiate(line2);
            myLine1 = road1.GetComponent <line>();
            myLine2 = road2.GetComponent <line>();
            Vector3[] forNode1 = NodeToVec(node1, false, (float)width);
            Vector3[] forNode2 = NodeToVec(node2, false, (float)width);
            //printVec(forNode1);
            //printVec(forNode2);
            myLine1.DrawLine(forNode1[0], forNode2[0]);
            myLine2.DrawLine(forNode1[1], forNode2[1]);
        }
    }
Exemplo n.º 2
0
    void drawLine(node node1, node node2)
    {
        GameObject road1 = Instantiate(line1);

        myLine1 = road1.GetComponent <line>();
        LineRenderer lineRenderer = myLine1.GetComponent <LineRenderer>();

        lineRenderer.material = new Material(Shader.Find("Particles/Additive"));
        lineRenderer.SetColors(Color.green, Color.green);
        myLine1.DrawLine(new Vector3(node1.xPos, node1.yPos, 0), new Vector3(node2.xPos, node2.yPos));
    }