- Home /
The name `MeshUtility' does not exist in the current context. help
Vector3 point = meshTransform.InverseTransformPoint (contact.point);
for (int i = 0; i < vertices.Length; i++) {
if ((point - vertices [i]).magnitude < damageRadius) {
vertices [i] += rot * ((localVector * (damageRadius - (point - vertices [i]).magnitude) / damageRadius) * cos + (new Vector3 (Mathf.Sin (vertices [i].y * 1000), Mathf.Sin (vertices [i].z * 1000), Mathf.Sin (vertices [i].x * 100)).normalized * (randomizeVertices / 500f)));
if (maximumDamage > 0 && ((vertices [i] - originalMesh [i]).magnitude) > maximumDamage) {
vertices [i] = originalMesh [i] + (vertices [i] - originalMesh [i]).normalized * (maximumDamage);
}
}
}
}
mesh.vertices = vertices;
mesh.RecalculateNormals ();
mesh.RecalculateBounds ();
MeshUtility.Optimize (mesh); <<=======
}
// Enabling contact particles on collision.
void CollisionParticles(Vector3 contactPoint){
for(int i = 0; i < contactSparkeList.Count; i++){
if(contactSparkeList[i].isPlaying)
return;
contactSparkeList[i].transform.position = contactPoint;
ParticleSystem.EmissionModule em = contactSparkeList[i].emission;
em.enabled = true;
contactSparkeList[i].Play();
}
}
Comment
We need more context. Check if $$anonymous$$eshUtility class need component with object
Answer by Maxence_Marchand · May 25, 2018 at 08:14 AM
Try adding using UnityEditor
at the beginning of your script, from what I read on the scripting API doc, MeshUtility
comes from there.
Answer by Bunny83 · May 25, 2018 at 10:03 AM
The MeshUtility class is an editor class which can only be used in an editor script. Your script doesn't look like an editor script but a runtime script. So you simply can not use it in your script.
Your answer
