21 this.mesh =
new Mesh();
23 this.triangles.Clear();
24 this.vertices.Clear();
28 this.vertices.AddRange(
new Vector3[]
30 new Vector3(0f, this.size.y,
this.size.z) + this.pos,
31 new Vector3(this.size.x,
this.size.y,
this.size.z) + this.pos,
32 new Vector3(this.size.x,
this.size.y, 0f) + this.pos,
33 new Vector3(0f, this.size.y, 0f) + this.pos
35 this.uv.AddRange(this.GetUVs(0));
40 this.vertices.AddRange(
new Vector3[]
42 new Vector3(0f, this.size.y, 0f) + this.pos,
43 new Vector3(this.size.x,
this.size.y, 0f) + this.pos,
44 new Vector3(this.size.x,
this.offset.y, 0f) + this.pos,
45 new Vector3(0f, this.offset.y, 0f) + this.pos
47 this.uv.AddRange(this.GetUVs(0));
50 this.mesh.SetVertices(this.vertices);
51 this.mesh.SetUVs(0, this.uv);
52 this.mesh.SetTriangles(this.triangles, 0);
53 if (this.calculateNormal)
55 this.mesh.RecalculateNormals();
60 public void AddTriangles()
62 this.triangles.AddRange(
new int[]
75 private Vector2[] GetUVs(
int id)
77 Vector2[] array =
new Vector2[4];
78 Vector2 vector =
new Vector2(1f / this.tiling.x, 1f /
this.tiling.y);
79 int num =
id % (int)this.tiling.x;
80 int num2 =
id / (int)this.tiling.x;
81 float num3 = this.UVPadding / this.tiling.x;
82 array[0] =
new Vector2((
float)num / this.tiling.x + num3, 1f - (
float)num2 /
this.tiling.y - num3);
83 array[1] =
new Vector2((
float)num / this.tiling.x + vector.x - num3, 1f - (
float)num2 /
this.tiling.y - num3);
84 array[2] =
new Vector2((
float)num / this.tiling.x + vector.x - num3, 1f - ((
float)num2 /
this.tiling.y + vector.y) + num3);
85 array[3] =
new Vector2((
float)num / this.tiling.x + num3, 1f - ((
float)num2 /
this.tiling.y + vector.y) + num3);
90 public Vector2 tiling = Vector2.one;
93 public float UVPadding = 0.02f;
96 public Vector3 pos =
new Vector3(0f, 0f, -1f);
99 public Vector3 offset;
102 public Vector3 size = Vector3.one;
108 public bool calculateNormal =
true;
114 private List<int> triangles =
new List<int>();
117 private List<Vector3> vertices =
new List<Vector3>();
120 private List<Vector2> uv =
new List<Vector2>();
123 private int triOffset;