Instantiate 80,000 objects

Is there a way to instantiate 80.000 cubes without freezing Unity or yielding errors shown below for the time-delayed generation of 80k gameobject cubes:

	void Start () {
		StartCoroutine (Inst());
	}
	
	IEnumerator Inst(){
		for(int i=0;i<80000;i++){
			
			if(i%1000==0)yield return new WaitForSeconds(2f);
			GameObject g = Instantiate (goCube,new Vector3(i,0,0),Quaternion.identity) as GameObject;
			g.name = "Cube"+i.ToString();
			
		}
	}

Unable to create broadphase entity.
UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)
c__Iterator0:MoveNext() (at Assets/scrawl/gencubestest.cs:15)

Actor Initialisation failed: returned NULL.
UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)
c__Iterator0:MoveNext() (at Assets/scrawl/gencubestest.cs:15)

Could not create actor. Maybe you are using too many colliders or rigidbodies in your scene?
UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)
c__Iterator0:MoveNext() (at Assets/scrawl/gencubestest.cs:15)

You can do this with a coroutine indeed.

private GameObject m_myObject;

    void Start()
    {
         StartCoroutine( InitOverNineThousandObject( 9001 ) );
    }
    
    IENumerator InitOverNineThousandObject( int nObjectToSpawn )
    {
       int i = 0;
       while( i < nObjectToSpawn ) 
            GameObject.Instantiate( m_myObject );
            i++;
            yield return null;
        }
    }     

for example =)

Forget my answer I see your answer jsut after my post :wink:

Refer to this recent question: Efficient visualization of 100000+ simple objects

Odds are you’re not going to have a lot of luck with 80,000 individual objects.