- Home /
Uv Mapping Quad
Hi Guys,
So I want to use one texture for my graphics. I want to put those graphics on a plane, and want to add the position of a graphic into the inspector.
I am using this code
using UnityEngine;
using System.Collections;
public class Art : MonoBehaviour
{
Mesh mesh ;
Vector2[] uvs ;
void Start()
{
mesh = GetComponent<MeshFilter>().mesh;
uvs = mesh.uv;
uvs[0] = new Vector2(0.0f, 1.0f);
uvs[1] = new Vector2(0.0f, 0.0f);
uvs[2] = new Vector2(1.0f, 1.0f);
uvs[3] = new Vector2(1.0f, 0.0f);
mesh.uv = uvs;
for (var i = 0; i < uvs.Length; i++)
Debug.Log(uvs[i]);
}
}
Problem one I have is that the image is rotated 90 degrees.
Problem two I have is how can I add the pixel position of a graphic
I know there are a lot of posts about this. But they only work on cubes. When I try them on quads it isn't working.
Are you sure that you're assigning proper uv coordinates to vertices? In a standard Unity Quad, vertex order is:
3--1
| |
0--2
Unity is left-handed. That's it. (It has to be one way or the other, and that's it.)
http://answers.unity3d.com/questions/266972/detecting-mesh-orientation.html
http://answers.unity3d.com/questions/293607/tiling-uv-mapping.html
http://answers.unity3d.com/questions/433582/manual-uv-mapping-of-a-primitive-cube.html
http://answers.unity3d.com/questions/423569/meshvertices-is-too-small.html
Note that if you work with mesh,
You must draw diagrams on paper.
.
Hope it helps!
note the asset mentioned here...
http://answers.unity3d.com/questions/435703/procedural-uniform-uvs-on-a-plane.html
also of interest...
http://answers.unity3d.com/questions/263302/vertices-array-in-mesh-vertices.html
http://answers.unity3d.com/questions/315059/how-to-improve-performance-while-generating-extrud.html
http://answers.unity3d.com/questions/417483/is-there-a-way-to-assign-meshverticesi-directly.html
http://answers.unity3d.com/questions/321428/adding-mesh-collider-in-run-time-slow.html
Your answer
Follow this Question
Related Questions
Animating the Mesh Morpher on function call. 0 Answers
How Can I make 3D Roads? 1 Answer
Moving an hole in a plane 0 Answers
How to make discontinuous UVs? 1 Answer
Flattening a mesh by deforming it 0 Answers