コード例 #1
0
ファイル: CLink.cs プロジェクト: ComicIronic/Diplomacy
    public void EstablishLink(CNode nodeA, CNode nodeB, CanvasCreator parent)
    {
        parentCC = parent;
        parentCC.links.Add(this);

        gameObject.name = "Link " + parentCC.links.Count.ToString();
        gameObject.transform.Translate(Vector3.back / 2);

        nodes.Add(nodeA);
        nodeA.links.Add(this);
        nodes.Add(nodeB);
        nodeB.links.Add(this);

        Mesh lineMesh = gameObject.AddComponent <MeshFilter> ().mesh;

        lineMesh.vertices  = new Vector3[4];
        lineMesh.triangles = new int[6] {
            0, 1, 2, 0, 2, 3
        };

        DrawLink();

        MeshRenderer newRenderer = gameObject.AddComponent <MeshRenderer> ();

        newRenderer.material.color  = nodeB.LinkColor();
        newRenderer.material.shader = Shader.Find("UI/Default");

        gameObject.AddComponent <MeshCollider> ();
    }
コード例 #2
0
ファイル: CLink.cs プロジェクト: ComicIronic/Diplomacy
    public void EstablishLink(CNode nodeA, CNode nodeB, CanvasCreator parent)
    {
        parentCC = parent;
        parentCC.links.Add (this);

        gameObject.name = "Link " + parentCC.links.Count.ToString ();
        gameObject.transform.Translate (Vector3.back / 2);

        nodes.Add (nodeA);
        nodeA.links.Add (this);
        nodes.Add (nodeB);
        nodeB.links.Add (this);

        Mesh lineMesh = gameObject.AddComponent<MeshFilter> ().mesh;
        lineMesh.vertices = new Vector3[4];
        lineMesh.triangles = new int[6] {0, 1, 2, 0, 2, 3};

        DrawLink ();

        MeshRenderer newRenderer = gameObject.AddComponent<MeshRenderer> ();
        newRenderer.material.color = nodeB.LinkColor ();
        newRenderer.material.shader = Shader.Find ("UI/Default");

        gameObject.AddComponent<MeshCollider> ();
    }