Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Mesh.AllocateWritableMeshData allocates what, how much ?

Discussion in '2023.1 Beta' started by equal, Jan 17, 2023.

  1. equal

    equal

    Joined:
    Dec 14, 2012
    Posts:
    77
    Hi,

    im not sure this is the proper section but lets try.

    When generating Meshes we have to use
    "Mesh.MeshDataArray meshDataArray = Mesh.AllocateWritableMeshData(1);"
    this gives us an MeshDataArray
    It containts MeshData.

    Since we define the Vertex and Indice Layout later, the MeshData, MeshDataArray and AllocateWritableMeshData can NOT know how big the Streams or the Data is that we work with or want to work with.

    I read throu:
    https://docs.unity3d.com/2020.1/Documentation/ScriptReference/Mesh.AllocateWritableMeshData.html
    https://docs.unity3d.com/2020.1/Documentation/ScriptReference/Mesh.MeshDataArray.html
    https://docs.unity3d.com/2020.1/Documentation/ScriptReference/Mesh.MeshData.html

    I would like to know, but i cant seem to find the awnsers:
    How big is MeshData in bytes?
    How much "Space" or "Memory" does Mesh.AllocateWritableMeshData allocate by default?
    (Is there a possible systemInfo that i missed?)
     
  2. aras-p

    aras-p

    Unity Legend

    Joined:
    Feb 17, 2022
    Posts:
    69
    It allocates a really small amount of memory, as far as I remember. Basically N structures for holding eventual mesh data.
     
    mahdi_jeddi likes this.
  3. equal

    equal

    Joined:
    Dec 14, 2012
    Posts:
    77
    Thank you very much, i can work with that