- Home /
Multiple MeshFilters for a GameObject
I have a Ribbon object, which I am creating dynamically and appending quads to it's mesh each frame. In order for it to remain visible as it twist due to backface-culling I have to have two meshes one with the normals facing one direction, and one with the normals facing the opposite direction (front/back).
Is it possible to have two meshes for one game object?
Here's how the mesh is created for reference: mesh = new Mesh(); filter = GetComponent(); filter.mesh = mesh;
vertices = new Vector3[ len * 4 ];
vertices[0] = new Vector3(0, 0, 0);
vertices[1] = new Vector3(width, 0, 0);
vertices[2] = new Vector3(0, height, 0);
vertices[3] = new Vector3(width, height, 0);
mesh.vertices = vertices;
// Create two triangles pointing using the vertices array index positions
triangles = new int[ len * 6 ];
// 1
triangles[0] = 0;
triangles[1] = 2;
triangles[2] = 1;
// 2
triangles[3] = 2;
triangles[4] = 3;
triangles[5] = 1;
mesh.triangles = triangles;
// Create the normals all pointing outward
normals = new Vector3[ len * 4];
normals[0] = -Vector3.forward;
normals[1] = -Vector3.forward;
normals[2] = -Vector3.forward;
normals[3] = -Vector3.forward;
mesh.normals = normals;
// Create UV's at each corner
uvs = new Vector2[ len * 4];
uvs[0] = new Vector2(0, 0);
uvs[1] = new Vector2(1, 0);
uvs[2] = new Vector2(0, 1);
uvs[3] = new Vector2(1, 1);
mesh.uv = uvs;
just have them all in one mesh. or, use submeshes if you like. or very simply (if you wanted to) have two gameObjects and group those inside another gameObject
Well, the simplest answer is just 'NO'. At least @Fattie is suggesting an alternative.
Well if you look at all the rude things @fattie was saying along with his answer, that he then removed you can understand why I would reply in such a way.
"@1day could you please TIC$$anonymous$$ ANY ANSWER HERE, TO CLOSE OUT THE QUESTION. It's yoru job as the OP. Don't hesitate to ask a new question of interest
ITS THE ROUND SY$$anonymous$$BOL -- WITH A TIC$$anonymous$$ IN THE $$anonymous$$IDDLE
cheers"
1day, there is nothing slightly rude about that. Please note that moderators (not me, other moderators) spend sometimes hours a day helping out. Nobody was being slightly rude. Anyway be sure to TIC$$anonymous$$ answers, please don't neglectt do it, cheers!
Of course I removed the answer -- because you said it wasn't what you wanted. That's what the remove button is for. This forum is supposed to have neat, concise correct answers in the future.
Your answer
Follow this Question
Related Questions
Updating Dynamic Mesh's Collider is Too Slow 1 Answer
Creating a mesh and assigning a material during edit time. 1 Answer
Is it possible to make vertices defined by a mesh and mesh filters animating? 0 Answers
How to prevent editor to set the scene dirty if a script changes a mesh (@ExecuteInEditMode) 1 Answer
Generate a highpoly sphere with mesh collider procedurally 2 Answers