c# loops not working yet no erors

hi so ive just started learning c# and ime coming across a problem with loops where despite no erors coming up the loop dosent seem to be working if i put print in it dosent print anything out but if i put it before it dose i dont know whether its just something in c# ime un aware of but i never had this problem with Js anyway here my code its around line 40 where the problem is

`using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class MapGen : MonoBehaviour {

public List<Chunk> Builders;
// Create a texture and fill it with Perlin noise.
// Try varying the xOrg, yOrg and scale values in the inspector
// while in Play mode to see the effect they have on the noise.
public int MapGenSize;
// Width and height of the texture in pixels.
public Transform ChunkPreFab;
public int pixWidth;
public int pixHeight;

// The origin of the sampled area in the plane.
public float xOrg;
public float yOrg;

// The number of cycles of the basic noise pattern that are repeated
// over the width and height of the texture.
public float scale = 1.0F;

public Texture2D noiseTex;
public Color[] pix;

void Start () {
	// Set up the texture and a Color array to hold pixels during processing.
	xOrg = Random.Range(-10,10);
	yOrg = Random.Range(-10,10);
	noiseTex = new Texture2D(pixWidth, pixHeight);
	pix = new Color[noiseTex.width * noiseTex.height];
	CreateChunks ();
	renderer.material.mainTexture = noiseTex;

public void CreateChunks (){
	for (int x = 0; x < MapGenSize; ++x) {		// this is the part that isnt working 
		for (int z = 0; z < MapGenSize; ++z) {
			Transform clone = Instantiate(ChunkPreFab, new Vector3(x * 20, 0, z * 20), Quaternion.identity) as Transform;
			clone.parent = transform;
			clone.GetComponent<Chunk>().GenScript = this;
			clone.GetComponent<Chunk>().BDataStore = transform.GetComponent<BlockData>();

public void CalcNoise() {
	int y = 0;
    while (y < noiseTex.height) {
        int x = 0;
        while (x < noiseTex.width) {
            float xCoord = ((xOrg + x) / noiseTex.width) * scale;
            float yCoord = ((yOrg + y) / noiseTex.height) * scale;
            float sample = Mathf.PerlinNoise(xCoord, yCoord);
            pix[y * noiseTex.width + x] = new Color(sample, 0, 0);
	// Copy the pixel data to the texture and load it into the GPU.

i thought it might be something to do with using the variables x and y multiple times in each class any help would be much aprechated

OK if the value is different from what the inspector is showing try commenting out it’s declaration.

This should achieve two things:

  1. It will generate compiler errors for every line that accesses the variable.

  2. clear the serialised value in the inspector, the when you uncommented the declaration it will start “fresh”.