How can i edit this script to make these objects spawn infinitely?

Im working on a space project and i would like the game objects to spawn infinitely as you explore the galaxies, solar systems and more. My question is, how can I manipulate this script to spawn these objects infinitely? How can I get them to spawn as you travel? Here is an example of one of my spawning scripts:

public class AstroidSpawner : MonoBehaviour {

public GameObject Astroid;
public int xPos;
public int zPos;
public int yPos;
public int SpawnNumber;
public bool spawningActive;

void Start()

{
    StartCoroutine(EnemySpawn());
}

IEnumerator EnemySpawn()
{
    while (SpawnNumber < 10000)
    {
        Debug.Log(xPos);
        xPos = Random.Range(1, 10000);
        zPos = Random.Range(1, 10000);
        yPos = Random.Range(1, 10000);
        Instantiate(Astroid, new Vector3(xPos, yPos, zPos), Quaternion.identity);
        yield return new WaitForSeconds(0.0001f);
        SpawnNumber += 1;

    }

}

}

change while (SpawnNumber < 10000) to while(true), then it will be infinite, if that is what you mean, but I would change the range to be based on where your player is, like get things to spawn in a donut around your player. Unless you want to see things spawn in, depends on what you are going for.

I don’t recommend you use Instantiate for such a large amount of objects, it would consume a lot of resources, it’s not recommended.

we can save that ram using Object Pooling
this is a very good model: OBJECT POOLING in Unity - YouTube