@@ -32,18 +32,44 @@ public MixedRealityRaycastHit(bool raycastValid, RaycastHit hitInfo)
32
32
barycentricCoordinate = hitInfo . barycentricCoordinate ;
33
33
distance = hitInfo . distance ;
34
34
triangleIndex = hitInfo . triangleIndex ;
35
- textureCoord = hitInfo . textureCoord ;
35
+
36
36
MeshCollider meshCollider = hitInfo . collider as MeshCollider ;
37
37
if ( meshCollider == null || meshCollider . sharedMesh . isReadable )
38
38
{
39
+ #if UNITY_2019_4_OR_NEWER
40
+ if ( meshCollider . sharedMesh . HasVertexAttribute ( UnityEngine . Rendering . VertexAttribute . TexCoord0 ) )
41
+ {
42
+ textureCoord = hitInfo . textureCoord ;
43
+ }
44
+ else
45
+ {
46
+ textureCoord = Vector2 . zero ;
47
+ }
48
+
49
+ if ( meshCollider . sharedMesh . HasVertexAttribute ( UnityEngine . Rendering . VertexAttribute . TexCoord1 ) )
50
+ {
51
+ textureCoord2 = hitInfo . textureCoord2 ;
52
+ lightmapCoord = hitInfo . lightmapCoord ;
53
+ }
54
+ else
55
+ {
56
+ textureCoord2 = Vector2 . zero ;
57
+ lightmapCoord = Vector2 . zero ;
58
+ }
59
+ #else
60
+ textureCoord = hitInfo . textureCoord ;
39
61
textureCoord2 = hitInfo . textureCoord2 ;
62
+ lightmapCoord = hitInfo . lightmapCoord ;
63
+ #endif
40
64
}
41
65
else
42
66
{
67
+ textureCoord = Vector2 . zero ;
43
68
textureCoord2 = Vector2 . zero ;
69
+ lightmapCoord = Vector2 . zero ;
44
70
}
71
+
45
72
transform = hitInfo . transform ;
46
- lightmapCoord = hitInfo . lightmapCoord ;
47
73
collider = hitInfo . collider ;
48
74
}
49
75
else
0 commit comments