- Home /
Please help me! Setting UVs on plane using World Space
Hello. I've made a C# script that generates triangle mesh with 3 Vector3 points.
and 3 points keep changing everytime the triangle mesh pops up.
triangle = new GameObject ("triangle", typeof(MeshFilter), typeof(MeshRenderer));
triangle.transform.position = new Vector3(0,0,-0.1f);
vertices = new Vector3[]{pointA, pointB, pointC};
triangles = new int[] {1,0,2};
Vector2[] uv = {new Vector2(0,0)
,new Vector2(1,0)
,new Vector2(0,1)
};
mesh = new Mesh();
mesh.vertices = vertices;
mesh.triangles = triangles;
mesh.uv = uv;
meshFilter = triangle.GetComponent<MeshFilter>();
meshRenderer = triangle.GetComponent<MeshRenderer>();
meshRenderer.material = matTriangle;
meshFilter.mesh = mesh;
I tried to put meterial on this triangle dynamically but the texture looks twisted.
how can I get a nice flat image like it's stuck in the background and masked with triangle? (like triangle shaped spot light)
the answers said that I should set UV in WorldSpace but I have no idea with WorldUV... :(
I've been searching for WorldUV for weeks but nothing was like my project.
someone please be my hero... thank you for reading by the way!
Your answer
Follow this Question
Related Questions
What are some good resources for learning the basics of Meshes, UV mapping, textures? 2 Answers
How would you go about designing and implementing an indoor level? 2 Answers
Generate UV Lightmap on large causes crash 1 Answer
Adding a UV-map material in Unity 5 not working 2 Answers
UVs are not mapped properly in my unity surface shader 0 Answers