Question by
TheDogePwner · Sep 26, 2015 at 01:08 AM ·
transformprefabparentinstantiation
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!
Comment
Answer by Trlgger · Oct 02, 2015 at 01:04 PM
myBulletObj.transform.SetParent(this.transform); is what your looking for.