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> (); }
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> (); }