private Material material;
protected void ApplyMesh(Vector3[] verts, Vector4[] uv, Color[] colors, List<int> triangles, Bounds bounds, Material material = null) {
this.material = material == null ? SharedMaterial : material;
if (m_SharedMesh == null) {
m_SharedMesh = new Mesh();
m_SharedMesh.name = this.GetType().Name;
m_SharedMesh.MarkDynamic();
}
if (m_SharedTexture != null) SharedMaterial.mainTexture = m_SharedTexture;
m_SharedMesh.bounds = bounds;
m_SharedMesh.SetVertices(verts);
m_SharedMesh.SetNormals(normals);
m_SharedMesh.SetUVs(0, uv);
if (colors != null && colors.Length > 0)
m_SharedMesh.SetColors(colors);
m_SharedMesh.SetTriangles(triangles, 0);
}
public void Graphic(Material material = null) {
if (m_SharedMesh == null) return;
Material mat = material == null ? SharedMaterial : material;
Graphics.DrawMesh(m_SharedMesh, transform.position, Quaternion.identity, mat, 0);
}
