Instantiate large amount of objects in edit mode

Hi, want to generate 100*100 objects in my scene, in the editor.

I have my code to generate them at runtime, but its done using coroutine, and coroutine won’t work in edit mode.

//So I have something like that for runtime
IEnumerator Generate()
	{
		for(int x = 0 ; x < 100 ; x ++)
		{
			for(int y = 0 ; y < 100 ; y ++)
			{
				GameObject o = new GameObject("object");
				
				o.transform.position = new Vector3(x,y,0);
			}
			
			yield return null;
		}
	}

Did someone already face the same problem and have a solution ?
How can I generate my objects not in one big frame that’ll freeze my unity ?

Thanks

hmmm, just make it function, not coroutine. For example :

public class Generator : MonoBehaviour
{ 
     public void Generate()
     {
         for(int x = 0 ; x < 100 ; x ++)
         {
             for(int y = 0 ; y < 100 ; y ++)
             {
                 GameObject o = new GameObject("object");
                 
                 o.transform.position = new Vector3(x,y,0);
             }            
             
         }
     }
}

[CustomEditor(typeof(Generator ))]
public class GeneratorEditor: Editor 
{
    public override void OnInspectorGUI()
    {
        if (GUILayout.Button("CREATE OBJECTS"))
        {
            ((Generator)target).Generate();
        }
    }
}