I’ve broken it down into it’s simplest form. This is sending me to a ward.
I start with this object:
I run this script on it:
public class MeshGenTest : MonoBehaviour
{
public GameObject originalObject;
void Start()
{
MeshFilter meshFilter = originalObject.GetComponent<MeshFilter>();
Mesh newMesh = new();
newMesh.vertices = meshFilter.sharedMesh.vertices;
newMesh.triangles = meshFilter.sharedMesh.triangles;
newMesh.normals = meshFilter.sharedMesh.normals;
meshFilter.sharedMesh = newMesh;
}
}
Or maybe this one:
public class MeshGenTest : MonoBehaviour
{
public GameObject originalObject;
void Start()
{
MeshFilter meshFilter = originalObject.GetComponent<MeshFilter>();
Mesh newMesh = new();
newMesh.vertices = meshFilter.sharedMesh.vertices;
newMesh.triangles = meshFilter.sharedMesh.triangles;
newMesh.normals = meshFilter.sharedMesh.normals;
newMesh.RecalculateNormals();
meshFilter.sharedMesh = newMesh;
}
}
Or maybe this one:
public class MeshGenTest : MonoBehaviour
{
public GameObject originalObject;
void Start()
{
MeshFilter meshFilter = originalObject.GetComponent<MeshFilter>();
Mesh newMesh = new();
newMesh.vertices = meshFilter.mesh.vertices;
newMesh.triangles = meshFilter.mesh.triangles;
newMesh.normals = meshFilter.mesh.normals;
newMesh.RecalculateTangents();
newMesh.RecalculateBounds();
newMesh.RecalculateNormals();
meshFilter.mesh = newMesh;
}
}
Every single one returns this mesh like this. Everything I try.
This is me using a normal draw-er script I found online to show that the normals are correct:
This is me probuilderizing the mesh and it’s perfectly fine:
What stupid thing am I missing?