How to draw mesh on texture,How to draw Mesh to texture
I want to procedurally generate a Mesh and draw it onto a texture
I found this on stack overflow which is pretty much what I wanted to do https://stackoverflow.com/questions/44232358/render-mesh-to-rendertexture-convert-to-texture2d
I tried out his code but if I include the Graphics.DrawMeshNow() and run it, the editor would freeze (the window still responds, but I can't click on anything in the editor. It response to right click though...). I simplified my code to the following:
private void CreateTexture(Mesh mesh)
{
RenderTexture renderTexture = new RenderTexture(128, 128, 24);
Graphics.SetRenderTarget(renderTexture);
graphics.DrawMeshNow(mesh, Vector3.zero, Quaternion.identity);
}
Can someone tell me what I did wrong? And also, can someone explain to me the code from stack overflow? I am still pretty new to the graphics side of unity, and I don't understand it fully. Thanks
Your answer
![](https://koobas.hobune.stream/wayback/20220612182744im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to pass a RInt RenderTexture to a ComputeShader? 0 Answers
Mesh & Shadow crash on Android platform build 0 Answers
How to efficiently lay down 3D level architecture like tiles? 0 Answers
How could I implement a "border" system for my medieval game? 0 Answers
All my circle sprites gets a messed up squarish mesh 1 Answer