Instantiate prefabs before runtime, inside editor

How do I instantiate prefabs so I can interract with them in the editor, without the game running? Instantiating prefabs is not the problem, but to do it once to create a map for the editor is what I need some help with.

I have searched for this online without any good results, so hopefully someone here knows a good way to do this :slight_smile:

Thanks in advance.


I know that I can simply drag a prefab to my editor.
Say I want a 10x10x10 cube made up from smaller same-sized cubes. Instead of dragging in 1000 prefabs att an exact location, I want to add them from script, something like this:

for(int i1=0;i1<10;i++){
   for(int i2=0;i2<10;i2++){
      for(int i3=0;i3<10;i3++){
          InstantiateIntoEditorBeforeRuntime(Resources.Load("myPrefab"), Vector3(i1,i2,i3));

(something like that)

Use PrefabUtility.InstantiatePrefab to do the instantiation. The manual page have an example similar to what you need (add three inlined loops and you are done).

IMHO, a 10x10x10 cube of objects will be strange to manage in editor. I wonder if that’s really necessary… :slight_smile: