Search Unity

How to create a polygon in runtime?

Discussion in 'World Building' started by casion0914, Dec 17, 2019.

  1. casion0914

    casion0914

    Joined:
    Feb 26, 2013
    Posts:
    5
    Hi all,I want to create a polygon in runtime,not in editor window. All points are given。
    Look this code, it doesn't work ,where is the mistake? Thank you!

    Code (CSharp):
    1. Polygon.points[0] = Vector3.zero;
    2.  
    3.             Polygon.points[1] = new Vector3(1, 0, 0);
    4.  
    5.             Polygon.points[2] = new Vector3(1, 0, 1);
    6.  
    7.             Polygon.points[3] = new Vector3(1, 0, 2);
    8.  
    9.             Polygon.points[4] = new Vector3(0, 0, 1);
    10.  
    11.             Polygon.mesh.ToMesh();
    12.             Polygon.mesh.Refresh();