Answer the question
In order to leave comments, you need to log in
Why in Unity3D does RaycastHit.textureCoord always return 0.0 after building the project?
I need to get the color of a pixel from a texture when a Raycast ray collides with an object. In the unity editor, everything works fine, the coordinates of the collision of the ray and the color of the pixel are determined. After building the application, RaycastHit.textureCoord always returns coordinates (0,0), so the color of the pixel is also incorrect. Has anyone encountered such a problem? And how can you solve it?
A fragment of the code for obtaining the texture of an object when a ray collides with a surface and determining the color of a pixel:
Texture2D tex = (Texture2D)Calc_Data.hit_center.collider.gameObject.GetComponent().material.mainTexture; // Get texture of object
color_pixcel = tex.GetPixelBilinear(Calc_Data.hit_center.textureCoord.x, Calc_Data.hit_center.textureCoord.y); // Get color from texture
The object itself:
Object material: Object
texture:
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question