Can I scale an object at runtime?

I’m trying to create a “progress” bar in worldspace. I made one by instantiating multiple cubes, one top of the other, but that seems like a waste of resources. Is there any way I can create a cube and change it’s Y or X scale at runtime?

You could do this:

transform.localScale = new Vector3(1, 1, 1);
transform.position += new Vector3(0.5, 0, 0);
(However long you want to wait)
transform.localScale = new Vector3(2, 1, 1);
transform.position += new Vector3(0.5, 0, 0);

…and so on

or

transform.localScale += new Vector3(1, 0, 0);
transform.position += new Vector3(0.5, 0, 0);
(However long you want to wait)
transform.localScale += new Vector3(1, 0, 0);
transform.position += new Vector3(0.5, 0, 0);

…and so on