I am using a script to instantiate a lot of instances from a few prefabs, and I want this to happen in edit mode. If I use [ExecuteInEditMode] in my script, the instances appear correctly in the editor, but each time I enter game mode a copy is generated. Without [ExecuteInEditMode], the objects appear only in game mode (but I would like to see them in edit mode as well, before entering game mode).
How can I prevent game mode from generating that copy?
My basic script structure is this:
[ExecuteInEditMode]
public class InstantiateTest : MonoBehaviour
{
public GameObject prefab;
void Start()
{
var newObject = Instantiate(prefab, new Vector3(0,0,0), Quaternion.identity);
}
void Update()
{
// empty
}
}
The script is attached to an Empty in the scene.