Understanding mesh volume

I wanted to know how calculate a mesh volume so I read these threads:


I tested all these stuff with cubes and spheres.
It works, but not how I expected. I didn’t understand why I change the object scale and the volume value does not change. Even if transform the vertice position to world position the result is the same.
Or I didn’t understand what approach I’m looking for.
Any tips? thanks in advance.

By scaling the object, you mean scaling the transform of the gameObject I guess? If that’s the case, it doesn’t affect the mesh data in any way. The mesh is used for rendering on the same GO, but the data in the mesh is the same - it’s not scaled.
If you want to calculate a volume of a mesh attached to a specific gameObject, you will need to do it on the gameObject level - calculate the volume of the mesh, then multiply it by the lossy scale of the transform the renderer is attached to. And by that I mean multiplying the volume (which is a scalar) by every element of the scale vector.