GameObject enemy = Instantiate(spawnObject,spawnPosition,spawnObject.transform.rotation) as GameObject; enemy.transform.parent = transform;
The code above generates the expected result when I test my game in game mode, however I get an error message:
"Setting the transform parent that is in the collection is disabled to prevent data corruption."
Yes, the spawnObject variable contains prefab, however creating a new GameObject should fix the problem, I suppose?
source share