unity c# how to modify the size of a gameobject code example

Example 1: unity set object scale

//gets the local scale of an object
vector3 local = transform.localScale;

//sets the local scale of an object
transform.localScale = new Vector3(scaleX,scaleY,scaleZ);

//gets the world scale of the object but is read only
vector3 world = transform.lossyScale;

Example 2: getting the size of a gameobject

//Most common
transform.localScale
//People say this works
//Actual size of mesh , scaled to localScale
objectSize = Vector3.Scale(transform.localScale, GetComponent().mesh.bounds.size);