@@ -40,41 +40,45 @@ public MixedRealityRaycastHit(bool raycastValid, RaycastHit hitInfo)
40
40
textureCoord2 = hitInfo . textureCoord2 ;
41
41
lightmapCoord = hitInfo . lightmapCoord ;
42
42
}
43
- else if ( meshCollider . sharedMesh . isReadable )
43
+ else
44
44
{
45
- #if UNITY_2019_4_OR_NEWER
46
- if ( meshCollider . sharedMesh . HasVertexAttribute ( UnityEngine . Rendering . VertexAttribute . TexCoord0 ) )
47
- {
48
- textureCoord = hitInfo . textureCoord ;
49
- }
50
- else
45
+ Mesh sharedMesh = meshCollider . sharedMesh ;
46
+ if ( sharedMesh != null && sharedMesh . isReadable )
51
47
{
52
- textureCoord = Vector2 . zero ;
53
- }
48
+ #if UNITY_2019_4_OR_NEWER
49
+ if ( sharedMesh . HasVertexAttribute ( UnityEngine . Rendering . VertexAttribute . TexCoord0 ) )
50
+ {
51
+ textureCoord = hitInfo . textureCoord ;
52
+ }
53
+ else
54
+ {
55
+ textureCoord = Vector2 . zero ;
56
+ }
54
57
55
- // This checks for TexCoord1, since textureCoord2 and lightmapCoord both query that index
56
- // via CalculateRaycastTexCoord(collider, m_UV, m_Point, m_FaceID, 1); (the last parameter is the index)
57
- if ( meshCollider . sharedMesh . HasVertexAttribute ( UnityEngine . Rendering . VertexAttribute . TexCoord1 ) )
58
- {
58
+ // This checks for TexCoord1, since textureCoord2 and lightmapCoord both query that index
59
+ // via CalculateRaycastTexCoord(collider, m_UV, m_Point, m_FaceID, 1); (the last parameter is the index)
60
+ if ( sharedMesh . HasVertexAttribute ( UnityEngine . Rendering . VertexAttribute . TexCoord1 ) )
61
+ {
62
+ textureCoord2 = hitInfo . textureCoord2 ;
63
+ lightmapCoord = hitInfo . lightmapCoord ;
64
+ }
65
+ else
66
+ {
67
+ textureCoord2 = Vector2 . zero ;
68
+ lightmapCoord = Vector2 . zero ;
69
+ }
70
+ #else
71
+ textureCoord = hitInfo . textureCoord ;
59
72
textureCoord2 = hitInfo . textureCoord2 ;
60
73
lightmapCoord = hitInfo . lightmapCoord ;
74
+ #endif
61
75
}
62
76
else
63
77
{
78
+ textureCoord = Vector2 . zero ;
64
79
textureCoord2 = Vector2 . zero ;
65
80
lightmapCoord = Vector2 . zero ;
66
81
}
67
- #else
68
- textureCoord = hitInfo . textureCoord ;
69
- textureCoord2 = hitInfo . textureCoord2 ;
70
- lightmapCoord = hitInfo . lightmapCoord ;
71
- #endif
72
- }
73
- else
74
- {
75
- textureCoord = Vector2 . zero ;
76
- textureCoord2 = Vector2 . zero ;
77
- lightmapCoord = Vector2 . zero ;
78
82
}
79
83
80
84
transform = hitInfo . transform ;
0 commit comments