Create Custom Mesh Post-Processor
Mesh post-processor can be used to alter the geometry after the decal has been projected. This method can be used to change the vertex positions, UVs, etc.
using UnityEngine; using ch.sycoforge.Decal.Projectors.Geometry; public class CustomProcessor : IMeshProcessor { public void Process(IMesh mesh) { // Iterate over triangles for (int i = 0; i < mesh.TriangleIndices.Count - 3; i += 3) { int t1 = mesh.TriangleIndices[i]; int t2 = mesh.TriangleIndices[i + 1]; int t3 = mesh.TriangleIndices[i + 2]; Vector3 a = mesh.Vertices[t1]; Vector3 b = mesh.Vertices[t2]; Vector3 c = mesh.Vertices[t3]; Vector3 ab = b - a; Vector3 ac = c - a; // Make something with data } } }
Each custom processor needs to implement the IMeshProcessor interface.
CustomProcessor processor = new CustomProcessor(); ... EasyDecal decal = EasyDecal.ProjectAt(DecalPrefab.gameObject, parent, position, averageNormal); decal.MeshProcessors.Add(processor);
The custom processor can be hooked to the decal instance as shown in the snippet above.