An error occurs when trying to set a child to my GameObject in script
问题 GameObject enemy = Instantiate(spawnObject,spawnPosition,spawnObject.transform.rotation) as GameObject; enemy.transform.parent = transform; The above code generates the expected result when I test my game in game mode, however I'm gettting this error message: "Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption." Yes, the spawnObject variable contains a prefab, however creating a new GameObject should have fixed the problem, I assume? 回答1: Check