Question is in the title. I’m getting errors when setting the colors of my ProBuilder mesh.
Context: I’m working on a custom vertex color painting tool and attempting to set the colors of the ProBuilder mesh I’m painting. I’m doing this with Visual Scripting but principles here should be the same as traditional script. I’m using 3 lists: Existing Colors, Painted Vertices, New Colors.
-
Use Pro Builder Mesh Colors and loop through them and store in an Existing Colors list.
-
Loop through Pro Builder Mesh Positions and check if the positions are within the radius of my paint brush. If it’s in range I store its index to a Painted Vertices list.
-
Loop through the Existing Colors list and check if its index is contained in the Painted Vertices list. If it is I add the color I’m using on my paint brush to the New Colors list, if it’s not I add the already existing color to the New Colors list.
-
Use Pro Builder Mesh Set Colors to set the colors of the PB mesh from the New Colors list.
-
Pro Builder Mesh Refresh all to refresh the mesh.
After doing this I’m getting various forms of the error (uv, normal, tangents, colors etc): the Mesh.tangents is out of bounds. The supplied array needs to be the same size as the Mesh.vertices array.
I’m not sure why the list is becoming longer than it was previously just from setting the colors. It’s hard to find documentation on how to approach changing ProBuilder meshes using the API. Would love some insight if anyone has it.