Sprite To Uv Mesh

Hi i try apply new uv based on RaycastHit hit;

for set sprite Information and apply new UV to the quad selection

for i need 3 think’s

  1. sprite position how return it
  2. quad face selection i see Meshtopology.quads but i have no acces to it
    Mesh mesh = meshCollider.sharedMesh;
    MeshTopology topo = mesh.GetTopology(0);
  3. apply uv

know if it’s possible it’s can be already good answer

Yes sorry my trouble is maybie hard to understand and my explain can be better
anybody can help please just give the way where’s i can oriented my search thank’s
:slight_smile:

so i found

rect rec = sprite.textureRect;

result this debug

rec(x:43.00, y:317.00, width:181.00, height:132.00)

with that’s i need complete this list

float Top_Left_min = 0;
float Top_Left_max = 0;
float Top_Right_min = 0;
float Top_Right_max = 0;
float bottom_Left_min = 0;
float bottom_Left_max = 0;
float bottom_Right_min = 0;
float bottom_Right_max = 0;

the biggest trouble is for uv we need quad
and for this time only triangles is enable

ok i have make the start now take pause
see later if i have time to back on it
so have somethink’s like this

float Top_Left_min = rec.x/atlas.width;
float Top_Left_max = rec.x /atlas.width+rec.width /atlas.width;
float Top_Right_min = rec.width /atlas.width;
float Top_Right_max = 1;
float bottom_Left_min = rec.y /atlas.height;
float bottom_Left_max = rec.y /atlas.height+rec.height /atlas.height;
float bottom_Right_min = 1;
float bottom_Right_max = 1;

Vector2[ ] theUVs = new Vector2[mesh.uv.Length];
theUVs = mesh.uv;
theUVs[4] = new Vector2(Top_Left_min, Top_Left_max );
theUVs[5] = new Vector2( Top_Right_min, Top_Right_max);
theUVs[8] = new Vector2( bottom_Left_min,bottom_Left_max );
theUVs[9] = new Vector2(bottom_Right_min, bottom_Right_max );
Debug.Log (“4UV”+theUVs[4]);
Debug.Log (“5UV”+theUVs[5]);
Debug.Log (“8UV”+theUVs[8]);
Debug.Log (“9UV”+theUVs[9]);
mesh.uv = theUVs;

close to goal now we can assign sprite to mesh

i found this post
http://forum.unity3d.com/threads/highlight-cube-face.36665/
talking about how use normal to get quad face

i continue to try apply sprite to mesh

anyone can help please

i looking other tool on asset store and no one do it

i found this What is the simple way of applying Texture Atlas to Unity - Questions & Answers - Unity Discussions
get interessing talking information