- Home /
Unity 4 with new function for setting parent of GameObject?
Hi there,
when I first started coding at my current project, I used something like gameObject.transform.parent = bla
to set the parent of a GameObject.
Now, I recently needed to set a GameObject's parent again and discovered the method SetParent() of gameObject.
_currentGO.SetParent(_dynamicObjects);
When my mates updated their code (they use early Unity 4 version, me the latest), they were told that this method does not exist. I couldn't find the changelogs for the Unity Updates.
Am I right with my assumption, that this function is quite new?
it seems that the parent transform position is not set with a function SetParent anymore but like any other transform: Gamobject.parent = transform;
http://docs.unity3d.com/Documentation/ScriptReference/Transform-parent.html
Answer by SarperS · May 03, 2013 at 09:29 AM
There is no such method in the Unity API as of now. Are you sure you don't have anything in your codebase that extend GameObject class and adds it that method? You can figure it out by doing a solution search with CTRL Shift F.
doh! ... there was a plugin who did some modifications to GameObject... a beginner's mistake
Your answer
![](https://koobas.hobune.stream/wayback/20220613101444im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Accessing a GameObject parent Object 2 Answers
Does inactive Objects eat up Performance? 1 Answer
Why is a parent object accessed through the transform? 2 Answers
Creating new Transform from existing objects Transform to Instantiate object 1 Answer
How can I get a parent GameObject of gameObject using Javascript? 6 Answers