- Home /
How do I texture a mesh runtime?
I need to texture my procedural mesh runtime. How do I do it? Unwrapping.GeneratePerTriangleUV seems to be removed. Also how do I get height and normalmaps to work?
I'm sorry, I moved this to forums: http://forum.unity3d.com/threads/texturing-and-uv-mapping-a-procedural-mesh.345001/ I also shared the code.
You don't "unwrap" it. You just assign the vertex indices to the UV array of the mesh in the right order. Take a look at the Scripting API for $$anonymous$$esh.uv.
Answer by Avash · Aug 08, 2015 at 03:43 PM
Solution: material.mainTexture.wrapMode = TextureWrapMode.Repeat; and calculating tangents. Eric was kinda right but it didn't help me.
Answer by Eric5h5 · Aug 01, 2015 at 01:00 AM
Set the UV array for the mesh. Each entry in the array corresponds to the appropriate vertex in the vertex array for the mesh. What values you use depends entirely on how you want to texture the mesh.
I still don't understand how do I set the UV array. Do I have to calculate it for every single surface?
Did you take a look at the Scripting API for the $$anonymous$$esh class and for $$anonymous$$esh.uv?
Also, take a look at this tutorial which should explain it:
Yes... I read that but.. I don't know how to do that with my mesh.. I want a continous texture.
I'm afraid to say that you are not really helpful. What have you tried so far? Post your code and then maybe other users will be able to help you. If are are not prepared to do your part of the process, which is reading, understanding, and trying, and then asking questions, it'll be hard to come to a solution.
As I said, what values you use depends on how you want to texture the mesh. If you don't understand how UVs work, then step 1 is to learn that. Then you can figure out what values would do what you want for whatever it is that you're generating.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Set UVs depending on input 1 Answer
Mesh texture not properly rendered 0 Answers
Best way to optimize mesh updating through code? 1 Answer
uv sub meshes in cube c# 0 Answers