Esempio n. 1
0
 void Awake()
 {
     canvasRenderer = gameObject.AddComponent <CanvasRenderer>();
     canvasRenderer.SetMaterial(material, null);
     mesh  = new Mesh();
     datas = new Linedata();
 }
Esempio n. 2
0
    void ADDLine(Vector3 start, Vector3 end, float width, ref Linedata ld)
    {
        float h         = 0.5f * width;
        float angle     = getAngle(start, end);
        int   initIndex = ld.verts.Count;

        ld.verts.Add(new Vector3(start.x + h * Mathf.Cos(angle / 180 * Mathf.PI),
                                 start.y + h * Mathf.Sin(angle / 180 * Mathf.PI)));
        ld.verts.Add(new Vector3(start.x - h * Mathf.Cos(angle / 180 * Mathf.PI),
                                 start.y - h * Mathf.Sin(angle / 180 * Mathf.PI)));
        ld.verts.Add(new Vector3(end.x + h * Mathf.Cos(angle / 180 * Mathf.PI),
                                 end.y + h * Mathf.Sin(angle / 180 * Mathf.PI)));
        ld.verts.Add(new Vector3(end.x - h * Mathf.Cos(angle / 180 * Mathf.PI),
                                 end.y - h * Mathf.Sin(angle / 180 * Mathf.PI)));

        ld.triganles.Add(initIndex);
        ld.triganles.Add(initIndex + 1);
        ld.triganles.Add(initIndex + 3);
        ld.triganles.Add(initIndex);
        ld.triganles.Add(initIndex + 2);
        ld.triganles.Add(initIndex + 3);
    }