Why is bounds size changing when rotating a sphere?

Step 1: Create a 3D Object → Sphere

Step 2: Attach this script

using UnityEngine;

public class SphereRendererRadius : MonoBehaviour {
    void OnDrawGizmos()
    {
        var rend = GetComponent<Renderer>();
        Gizmos.DrawWireCube(rend.bounds.center, rend.bounds.size);
    }
}

Step 3: rotate the sphere in inspector and watch the bounding box size changing.

It is expanding even though rotating a sphere shouldn’t (?) change its volume in any way.

Why is this happening?

I need to get the radius of sphere that migh not have collider regardless of its rotation. How to do that?

Ah, so bounds of renderer is not smallest bounding cube of what is rendered but just AABB of bounding box of mesh… sounds a little unintuitive, but ok. I guess finding out true BB of what is rendered would be too expensive…

anyway I found out the way to determine radius of arbitrarily rotated and scaled sphere:

        var rend = GetComponent<Renderer>();

        var bounds = GetComponent<MeshFilter>().sharedMesh.bounds;
        var x = bounds.size.x * transform.localScale.x;
        var y = bounds.size.y * transform.localScale.y;
        var z = bounds.size.z * transform.localScale.z;
        var radius = bounds.extents.magnitude;

        Gizmos.DrawWireCube(rend.bounds.center, new Vector3(x, y, z));

The bounding box for any mesh is always a cube, which is large enough to contain the mesh regardless of what shape it is. When you rotate the mesh, and therefore the bounding cube, the world-aligned volume that you’re creating with DrawWireCube changes appropriately.