How to give dynamically add mass to a gameobject from volume(collider.bounds.size) and density

I am trying to dynamically add mass to my gameobject by its size. My gameobjects are from a housing dataset, so things that may appear large for example a hollow box should not be that heavy. Any ideas

To calculate the mass you need to have an density for your item. The formula for mass is

m = V * p

But you can implement it without density if say density is 1. Then it just becomes

m = V

Then all you need to do is calculate the volume and you will have the mass.

void LateUpdate () {
   // Calculate mass
   float volume = transform.localScale.x * transform.localScale.y * transform.localScale.z;

   // Set the mass
  GetComponent<RigidBody> ().mass = volume;
}

Then if you ever want to implement density then its a simple change:

GetComponent<RigidBody> ().mass = mass * density;