Vector3 to Vector2 UV coordinates

I am attempting to get access to the UV coordinates of a (skinned) mesh tbased on where it was raycasted so that I made edit the texture using the Vector2 UV coords. I am aware of “RaycastHit.TextureCoord” and it works fantastic- however it is limited to only work IF the mesh has a mesh collider attached, and considering I am raycasting onto a skinned mesh, having a mesh collider attached is impossible.

How could I go about taking the Vector3 point in space and translating that to a Vector2 UV point in texture space?

Thanks for any insights!

I did this before but used a method similar to the second answer here (Collider on Skinned Mesh - Questions & Answers - Unity Discussions).

You use a mesh collider but only bake it when you do a raycast - if it’s active all the time it’s too slow.

Hey, I coincidentally implemented this approach just recently and got great results! Unfortunately there’s still quite a bit of overhead when the bake functions called- and even more so the higher poly you go :frowning:

I have a system that doesn’t get slower with high poly meshes because it’s shader based: Super Raycast.

You can get the uv like:

RaycastHitRenderer hitInfo;
if (SuperRaycast.PhysicsRaycast(ray, out hitInfo))
{
    // UV results
    Debug.Log(hitInfo.uv);
}