The question is answered, right answer was accepted
Assign an image as a texture to a mesh
Hello,
I have a set of 3D points, which I triangulate with Triangle.Net after bringing them into 2D. I want to assign a texture to those gameobjects, but it's not really working and I don't know why. Loading an image file is working great. It's working if I create a primitive gameobject g (plane or sphere), load the image (byte[] data = File.ReadAllBytes("path/to/image"); ) and assign it to the gameobject (Texture2D tex = new Texute2D(10, 10); and tex.loadData(data); and g.GetComponent().material.mainTexture = tex; ). But if I use those gameobjects for which I only have those 3D points, which I triangulate and for which I create not primitive objects, then it's not working. Those object have for the same image only one dark color. In the first picture is a plane (primitive object) with the image as a texture and it looks fine. The second picture is a gameobject after computing the mesh for it with just one color. What am i doing wrong or what do I have to change to assign the image properly?
Follow this Question
Related Questions
Is it possible to draw primitive shapes on to a Texture2D? 1 Answer
How to create a mesh for 2D maps with transparent parts, which is generated by software? 0 Answers
Texture2D to Plane: Array Index is Out of Range 1 Answer
How Can I Create My Own Textures? 3 Answers
Raycast doesn't find mesh 0 Answers