private void BuildDecal(Decal decal) { MeshFilter filter = decal.GetComponent <MeshFilter>(); if (filter == null) { filter = decal.gameObject.AddComponent <MeshFilter>(); } if (decal.renderer == null) { decal.gameObject.AddComponent <MeshRenderer>(); } decal.renderer.material = decal.material; if (decal.material == null || decal.sprite == null) { filter.mesh = null; return; } affectedObjects = GetAffectedObjects(decal.GetBounds(), decal.affectedLayers); foreach (GameObject go in affectedObjects) { DecalBuilder.BuildDecalForObject(decal, go); } DecalBuilder.Push(decal.pushDistance); Mesh mesh = DecalBuilder.CreateMesh(); if (mesh != null) { mesh.name = "DecalMesh"; filter.mesh = mesh; } }