I am trying to instantiate the following object to a child of the gameobject
this script resides:
var newEnergyPart = Instantiate<GameObject>(energyPart, energyBarLayout.transform.position, Quaternion.identity);
newEnergyPart.transform.SetParent(energyBarLayout.gameObject.transform);
However, It keeps giving me this error:
Setting the parent of a transform which resides in a Prefab Asset is disabled to prevent data corruption (GameObject: 'BarUnit(Clone)'). UnityEngine.Transform:SetParent(Transform)
I thought that making sure to set parent to an object set as n instantiated gameobject
would make the error go aways it keeps appearing.
energyBarLayout
a prefab? – Draco18s no longer trusts SE