I get this error Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption. UnityEngine.Transform:set_parent(Transform) Spawner:Spawn() (at Assets/Scripts/Spawner.cs:77) Spawner:Start() (at Assets/Scripts/Spawner.cs:53)
[/Users/build/builds/unity-iphone-1.5/iphone-1.1/Projects/../Runtime/Graphics/Transform.cpp line 161]
when I do this code
public GameObject monster1;
public GameObject monster2;
public Transform monster1Holder;
public Transform monster2Holder;
.... ...
GameObject monster = monster1;
int m = 1;
if (currentMonsterRatio > Random.RandomRange(0 , 100)) {
monster = monster2;
m = 2;
}
GameObject mn = (GameObject)Instantiate(monster,SpawnPoint(),Quaternion.identity);
((Monster)mn.GetComponent(typeof(Monster))).velocity += curentSpeedIncrease;
if (m==1) mn.transform.parent = monster1Holder;
else mn.transform.parent = monster2Holder;
line 77 is the second last line of code here. Also the parent is not changed. I know this code used to work because I could see the objects in the correct place in the hierarchy. I had to change prefab I was instantiating and now I get this error.
Thanks Yes that is what I did. I attached the wrong transforms to monster1Holder and monster2Holder.
– Ryuuguu