Engine/UnityNote
[Unity] 프리팹 Load한 후 parent를 변경해줄 때 에러
11월1일
2021. 9. 11. 03:01
Setting the parent of a transform which resides in a Prefab Asset is disabled to prevent data corruption
GameObject obj = Resources.Load<GameObject>("Prefabs/Item");
obj.transform.parent = content.transform;
코드에서 프리팹을 불러온 후 인스턴스화된 게임 오브젝트로 바꿔주지 않고 바로 parent를 변경하면 에러가 발생한다.
GameObject obj = Instantiate(Resources.Load<GameObject>("Prefabs/Item"));
obj.transform.parent = content.transform;