- Home /
AddAdditionalVertexStreams and static meshes
Hi
Is there any way to set AddAdditionalVertexStreams for mesh (MeshRenderer exacly) that is marked 'static' ? In short: I have plane, that have tens of instances in scene, some of those instances need to use modified .colors array, (data for this one is generated at runtime when the first 'Update' call of the script is made - or there is a better place for this ?) If mesh is marked as 'static' in editor, and I assign this custom colors array then the effect (in game) is that the mesh is displaced, and does not contain any of assigned color, if mesh is not marked as static, the all works fine. Here is the code: (called once, in 'Update()' section of script assigned to mesh) (all errors checking removed for simplicity)
MeshRenderer MRenderer = gameObject.GetComponent(); MeshFilter MF = gameObject.GetComponent();
var AdditionalMesh = new Mesh();
Vector3[] MeshVertices = new Vector3[ MF.mesh.vertexCount ]; Array.Copy( MF.mesh.vertices, MeshVertices, MeshVertices.Length );
AdditionalMesh.vertices = MeshVertices; AdditionalMesh.colors = PerVertexColorsArray; // the array is generated earier
AdditionalMesh.UploadMeshData( true );
MRenderer.additionalVertexStreams = AdditionalMesh;
If I cant't do this for static mesh, what are the consequences to make those meshes 'non-static' ? (I use umbra, and lightmaps - is there any trick to make them work with those meshes 'as if they were static ?')
Your answer
Follow this Question
Related Questions
How to use Vertex Colors 0 Answers
Changes to Mesh Vertex Colors Reset on Build 1 Answer
Vertex colors are being stripped after build 1 Answer
Best practice to change vertex color on a large amount of quads? 1 Answer
How to get the colors of the vertices in a mesh? [or average color of a triangle] 1 Answer