How do you change size of an object by its units rather than scale?

I need a game object to be exactly 10 units long in the z axis. I can try resizing the object while looking at the grids in scene mode to get a very close estimate, however when I do it that way, I can’t confirm that it’s exactly 10 units. It may be 10.0002 or something like that. Is there an option in Unity to do this? Or is there a way to do it with c#? Thanks for your help.

If you know the initial size of the object (for example, Mesh.bounds if you’re basing it on the extents of the object), then you can programmatically scale it to a precise target size.

public Vector3 targetSize = * 10.0f; // Example 10x scale

// ...

Mesh m = gameObject.GetComponent<MeshFilter>().sharedMesh;
Bounds meshBounds = m.bounds;
Vector3 meshSize = meshBounds.size;
float xScale = targetSize.x / meshSize.x;
float yScale = targetSize.y / meshSize.y;
float zScale = targetSize.z / meshSize.z;

transform.localScale = new Vector3(xScale, yScale, zScale);