set mesh vertex Color in the asset

Greetings ,

I’d like to know if there is a way to store the vertex colors directly in the meshes at object import, instead of assigning them on runtime .

Unity show a way to modifiy the mesh color here :

My process is this one at the moment :

  • creating programmatically an .obj ( vertices / faces )
  • linking each vertices with a colour in a .vco file ( as vertex color ) : this file acts like a dictionnary
  • attaching a script on each imported file, which will ''load'' the .vco file and create on the fly the mesh.color array...
  • what annoys me is using a dictionary , and assigning the vertex color on runtime via mesh.color.
    it works fine as a test on a cube ( 8 vertices => 24 vertex colors *)…

    but i project in one scene around 2.000 objects , 66.000 vertices per objects ( now that we can !) and i like to keep the assets clean right on their import… I cannot find any references regarding that mesh.color storage or how to assign the vertex color data directly in the asset .

    *why 24 and not 8 ? some hints here : c# - Set color for each vertex in a triangle - Stack Overflow

    @hexagonius thanks hexagonius ! by doing that, does unity ‘’ save ‘’ the mesh.colors array directly in the mesh ??

    hexagonius · 1 hour ago 1
    You can script your own asset importer that will execute logic on import.
    Unity - Scripting API: ModelImporter

    a cube has 24 vertices because it saves the normal for each, necessary to flat shade the sides