- Home /
how to convert sprite to mesh or to a polygon ???
i need the the sprite have the"mesh collide "with the particle collider! but the sprite can't add the "mesh filter",so i want use the sprite-wireframe to Extrusion a polygon! !
by the way i want to know: how to add the "tag"use the script and how to change component"World Particle Collider-Collision Energy Loss " use the script to change the value?? thank you!!:)!
A sprite does not have a wireframe. A sprite is likely some form of Quad. If you are using a polygon collider on the sprite, and if the polygon is a single path of points, you can use the Triangulator scrip from the Unity Wiki with the path to produce a mesh. But there is some heavy lifting involved in building this solution.
Answer by brzydal · Mar 07, 2016 at 09:22 PM
In general you can convert Sprite to Mesh with this:
Mesh SpriteToMesh(Sprite sprite)
{
Mesh mesh = new Mesh();
mesh.vertices = Array.ConvertAll(sprite.vertices, i => (Vector3)i);
mesh.uv = sprite.uv;
mesh.triangles = Array.ConvertAll(sprite.triangles, i => (int)i);
return mesh;
}
That actually looks like it would work. Though wouldn't you also need to add the $$anonymous$$eshFilter
and $$anonymous$$eshRenderer
?
I think you can assign that generated mesh directly to $$anonymous$$eshCollider, but I didn't try that yet.
vryzdal..can you help me please understanding lambda expression...
Your answer

Follow this Question
Related Questions
How do you bend a 2d texture in 3d?,How do you bend a 2D object in 3D? 0 Answers
Can I use a Mesh as a Sprite Mask? 0 Answers
Tool to make ONE flat sized mesh from a png/texture? 5 Answers
Low quality on Sprite and Line Renderer - not sharp enough 1 Answer
Converting multiple sprites in a single 0 Answers