Cannot Parent a Prefab Instantiated with Resource.Load()

Hello,

I instantiate a Prefab as follows:

GameObject myBulletObj = Instantiate ((GameObject) Resources.Load("Prefabs/Bullets/AK47Bullet")) as GameObject;
			myBulletObj .transform.parent = this.transform;
			myBulletObj .name = this.name + " Bullet";
			myBulletObj .transform.localPosition = new Vector3 (0f, 0.7f, 0.9f);

But I get the following error:

Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption

Why is this?
Thanks!

...bump...

...bump...

It works, thank you, you're awesome :DDD

1 Answer

1

myBulletObj.transform.SetParent(this.transform); is what your looking for.

co0l. please mark the answer correct