Wednesday, November 23, 2022
HomeGame Developmentunity - GameObject mesh.vertices array is empty

unity – GameObject mesh.vertices array is empty


I’ve an Icosphere GameObject:

enter image description here

I need to iterate over every of the faces and alter the fabric primarily based on their distance from the middle, nevertheless I do not appear to have the ability to retrieve the listing of vertices for the article:

void Begin()
{
    // Works
    _planetRenderer = GetComponent<Renderer>();
    _planetRenderer.sharedMaterial = Supplies.First(m => m.title == "Sand");

    // Cannot retrieve vertices
    MeshFilter gameObjMeshFilter = GetComponent<MeshFilter>();

    Debug.Log($"Middle: {rework.place}");
    Debug.Log($"Mesh Depend: {gameObjMeshFilter.mesh.vertices.Size}");
}

The vertexCount is returned as 43530, however vertices is an empty array:

enter image description here

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments