@@ -95,7 +95,8 @@ private void UpdateColliderType()
95
95
{
96
96
// attach new collider
97
97
var handleBounds = VisualUtils . GetMaxBounds ( GetVisual ( handle ) . gameObject ) ;
98
- var invScale = handleBounds . size . x == 0.0f ? 0.0f : config . HandleSize / handleBounds . size . x ;
98
+ float maxDim = VisualUtils . GetMaxComponent ( handleBounds . size ) ;
99
+ float invScale = maxDim == 0.0f ? 0.0f : config . HandleSize / maxDim ;
99
100
Vector3 colliderSizeScaled = handleBounds . size * invScale ;
100
101
Vector3 colliderCenterScaled = handleBounds . center * invScale ;
101
102
if ( config . HandlePrefabColliderType == HandlePrefabCollider . Box )
@@ -109,7 +110,7 @@ private void UpdateColliderType()
109
110
{
110
111
SphereCollider sphere = handle . gameObject . AddComponent < SphereCollider > ( ) ;
111
112
sphere . center = colliderCenterScaled ;
112
- sphere . radius = colliderSizeScaled . x * 0.5f ;
113
+ sphere . radius = VisualUtils . GetMaxComponent ( colliderSizeScaled ) * 0.5f ;
113
114
sphere . radius += VisualUtils . GetMaxComponent ( config . ColliderPadding ) ;
114
115
}
115
116
}
@@ -236,7 +237,8 @@ protected override void RecreateVisuals()
236
237
237
238
protected override void UpdateColliderBounds ( Transform handle , Vector3 visualSize )
238
239
{
239
- var invScale = visualSize . x == 0.0f ? 0.0f : config . HandleSize / visualSize . x ;
240
+ float maxDim = VisualUtils . GetMaxComponent ( visualSize ) ;
241
+ float invScale = maxDim == 0.0f ? 0.0f : config . HandleSize / maxDim ;
240
242
GetVisual ( handle ) . transform . localScale = new Vector3 ( invScale , invScale , invScale ) ;
241
243
Vector3 colliderSizeScaled = visualSize * invScale ;
242
244
if ( config . HandlePrefabColliderType == HandlePrefabCollider . Box )
@@ -248,7 +250,7 @@ protected override void UpdateColliderBounds(Transform handle, Vector3 visualSiz
248
250
else
249
251
{
250
252
SphereCollider collider = handle . gameObject . GetComponent < SphereCollider > ( ) ;
251
- collider . radius = colliderSizeScaled . x * 0.5f ;
253
+ collider . radius = VisualUtils . GetMaxComponent ( colliderSizeScaled ) * 0.5f ;
252
254
collider . radius += VisualUtils . GetMaxComponent ( config . ColliderPadding ) ;
253
255
}
254
256
}
0 commit comments