(Unity) Raycast & OcclusionObjects not working

I’ve been running a procedural generation of GameObjects to create a minecraft like terrain generation. This part works fine, however it needs optimising because it’s rendering too much at any given time, as such I have created an OcclusionScript.cs & OcclusionObject.cs which should stop the objects rendering if not seen, the issue here is that it’s not rendering anything at all (Screenshot attached).

public void GenerateTerrain()     {         for (int x = 0; x < sizeX; x++)             for (int z = 0; z < sizeZ; z++)             {                 int maxY = (int)(Mathf.PerlinNoise((x / 2 + seed) / terDetail, (z / 2 + seed) / terDetail) * terHeight);                 maxY += groundHeight;                  GameObject grass = Instantiate(blocks[0], new Vector3(x, maxY, z), Quaternion.identity) as GameObject;                 grass.transform.SetParent(GameObject.FindGameObjectWithTag("Environment").transform);                  for (int y = 0; y < maxY; y++)                 {                     int sandLayers = Random.Range(3, 9);                     if(y >= maxY - sandLayers)                     {                         GameObject sand = Instantiate(blocks[2], new Vector3(x, y, z), Quaternion.identity) as GameObject;                         sand.transform.SetParent(GameObject.FindGameObjectWithTag("Environment").transform);                     }                     else                     {                         GameObject stone = Instantiate(blocks[1], new Vector3(x, y, z), Quaternion.identity) as GameObject;                         stone.transform.SetParent(GameObject.FindGameObjectWithTag("Environment").transform);                     }                 }                  // Spawn player above grass                 if (x == (int)(sizeX / 2) && z == (int)(sizeZ / 2))                 {                     player = Instantiate(playerObj, new Vector3(x, maxY + 3, z), Quaternion.identity);                 }             }     } 

OcclusionObject.cs:

public class OcclusionObject : MonoBehaviour {      Renderer myRend;     public float displayTime;      private void OnEnable()     {         myRend = gameObject.GetComponent<Renderer>();         displayTime = -1;     }      // Update is called once per frame     void Update()     {         if(displayTime > 0)         {             displayTime -= Time.deltaTime;             myRend.enabled = true;         }else         {             myRend.enabled = false;         }     }       public void HitOcclude(float time)     {         displayTime = time;         myRend.enabled = true;     } } 

OcclusionScript:

public class OcclusionScript : MonoBehaviour {      public int rayAmount = 1500;     public int rayDistance = 300;     public float stayTime = 2;      public Camera cam;      public Vector2[] rPoints;      // Start is called before the first frame update     void Start()     {         cam = gameObject.GetComponent<Camera>();         rPoints = new Vector2[rayAmount];          GetPoints();     }      // Update is called once per frame     void Update()     {         CastRays();     }      void GetPoints()     {         float x = 0;         float y = 0;          for (int i = 0; i < rayAmount; i++)         {             if(x > 1)             {                 x = 0;                 y += 1 / Mathf.Sqrt(rayAmount);             }              rPoints[i] = new Vector2(x, y);             x += 1 / Mathf.Sqrt(rayAmount);          }     }      void CastRays ()     {         for (int i = 0; i < rayAmount; i++)         {             Ray ray;             RaycastHit hit;             OcclusionObject ocl;              ray = cam.ViewportPointToRay(new Vector3(rPoints[i].x, rPoints[i].y, 0));               if(Physics.Raycast(ray, out hit, rayDistance))             {                 if(ocl = hit.transform.GetComponent<OcclusionObject>())                 {                     ocl.HitOcclude(stayTime);                 }             }         }     } } 

Example of procedural GameObjects not rendering