Change size of mesh in script

Is there a way of changing mesh size in script? I tried this:

        private static Mesh CreatePrimitiveMesh(PrimitiveType type,int textureHeight = 64, int textureWidth = 64)
        {
            GameObject gameObject = GameObject.CreatePrimitive(type);
            
            Mesh mesh = gameObject.GetComponent<MeshFilter>().mesh;
            GameObject.Destroy(gameObject);
            int scaleX = textureWidth / unitSize;
            int scaleY = textureHeight / unitSize;


            mesh.vertices.ForEach(vertex =>
            {
                vertex.x *= scaleX;
                vertex.y *= scaleY;
            });

            mesh.RecalculateBounds();
            
            Debug.Log($"in Create: v0: {mesh.vertices[0]} v1: {mesh.vertices[1]} v2: {mesh.vertices[2]} v3: {mesh.vertices[3]}");
            return mesh;
        }

But it does literally nothing. Why is it so? How can I really rescale mesh?

@Zylkowski_a Based off your script, I recommend adjusting the transform.localScale of your gameObject, or did you want something more specific to mesh manipulation?

I hope you don’t still need an answer, but I will post this in case someone else wants to know. You need a reference to your object “public GameObject obj;”. Then, in a function, type this: “obj.localScale = new Vector3(x scale, y scale, z scale);”. Make sure that you call the function. I hope this helps someone.,I hope you don’t still need help, but you need a reference to your GameObject: “public GameObject obj;”. Then, use the code “obj.localScale = new Vector3(scale x, scale y, scale z);”. Make sure you have called the function through update or start. I hope this answered your question. Also, sorry for the late response, but I hope this will help someone.

The post I made before is wrong, sorry. You need to get a reference to its transform, not its GameObject.