Search Unity

GameObjects' Mesh using shared vertices

Discussion in 'General Graphics' started by jttarigan, Oct 11, 2019.

  1. jttarigan

    jttarigan

    Joined:
    Mar 13, 2018
    Posts:
    2
    Hi, newb here

    I am currently building a large terrain consists of multiple gameobjects. I'm required to store the vertex to a static array variable and since a lot of them is shard with multiple mesh, I can save a lot of memory space by directing them to use the same vertices. Is it possible for multiple gameObject with multiple mesh to have a shared vertices array? Currently, each gameObject has its own mesh and has an array of vertices. But I wonder if I could store these vertices in a static variable and tell the mesh to use the vertices from that array.

    Moreover, if I have this code:

    Vector3 vertices = new Vector3[6];
    // define the position of each vertices
    mesh.vertices = vertices;

    will it copy it's value to mesh.vertices array or simply pass the reference to mesh variable? If it is pass by value, then my architecture contains lots of memory redundancy.

    Thanks in advance