|
|
|
|
|
|
|
|
|
|
using UnityEngine; |
|
|
|
|
|
|
|
[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))] |
|
|
|
//[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
|
|
|
|
void Start() |
|
|
|
{ |
|
|
|
GenerateBarycentricData(); |
|
|
|
} |
|
|
|
//void Start()
|
|
|
|
//{
|
|
|
|
// GenerateBarycentricData();
|
|
|
|
//}
|
|
|
|
|
|
|
|
private void Reset() |
|
|
|
{ |
|
|
|
|
|
|
Mesh mesh = GetComponent<MeshFilter>().sharedMesh; |
|
|
|
|
|
|
|
SplitMesh(mesh); |
|
|
|
|
|
|
|
SetVertexColors(mesh); |
|
|
|
} |
|
|
|
|
|
|
|
public void GenerateData(Mesh mesh) |
|
|
|
{ |
|
|
|
SplitMesh(mesh); |
|
|
|
|
|
|
|
SetVertexColors(mesh); |
|
|
|
} |
|
|
|
|
|
|
|
void SetVertexColors(Mesh mesh) |
|
|
|
|
|
|
mesh.normals = newNormals; |
|
|
|
mesh.uv = newUvs; |
|
|
|
mesh.triangles = triangles; |
|
|
|
|
|
|
|
SetVertexColors(mesh); |
|
|
|
} |
|
|
|
} |