change public int based on InputField?

hey!
so i got this public int worldWidth; in my script

using UnityEngine;
using System.Collections;

public class WorldSpawn : MonoBehaviour {

	public GameObject block1; 

	public int worldSize = 10;

	public int worldWidth  = 10;
	public int worldHeight  = 10;

	public float spawnSpeed = 0;

	public void  Spwan () {
		StartCoroutine(CreateWorld());
	}

	IEnumerator CreateWorld () {
		for(int x = 0; x < worldWidth; x++) {
			yield return new WaitForSeconds(spawnSpeed);

			for(int z = 0; z < worldHeight; z++) {                
				yield return new WaitForSeconds(spawnSpeed);

				GameObject block = Instantiate(block1, Vector3.zero, block1.transform.rotation) as GameObject;
				block.transform.parent = transform;
				block.transform.localPosition = new Vector3(x, 0, z);
			}
		}
	}
}

and a text input field as a ui element somewhere else.
how can i change the int worldWidth in a way that it got the same value as the input field?

i thought i can use the “On Value Changed” event from the input field somehow. But i can not figure out how? or is there a better way to do this?

How to use the “On Value Changed” event: Unity - Manual: UnityEvents

There are a ton of video tutorials on UnityEvents as well.