Can't re-parent GameObject with Text(script) component.
When I run this code:
GameObject element = Instantiate(defaultOutputElement);
element.transform.parent = OutputContent.transform;
or this code:
GameObject element = Instantiate(defaultOutputElement, OutputContent.transform);
or this code:
GameObject element = Instantiate(defaultOutputElement);
element.transform.SetParent(OutputContent.transform);
I get this error:
Can't remove RectTransform because Text (Script) depends on it
Can anyone explain?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612151755im_/https://answers.unity.com/themes/thub/images/avi.jpg)