- Home /
Scale a prefab without reference to parent
Hi, I am adding a prefab to an empty GameObject at runtime. I want to change the scale of the prefab so I am changing the localscale:
transform.localscale = new Vector3(1,1,1);
however, because the parent has a scale or 1,0,1 the prefab's scale is 0,0,0 at runtime. How can I specifically determine the size of the prefab with no consideration of the parent?
Answer by Seth-Bergman · Aug 01, 2013 at 09:53 PM
I'm pretty sure you can't. Since the child inherits the scale of the parent, you can't add any y-scale to the object (even if you do, it will visibly remain as 0). However, your code is fine, I just tested it and the values do change. You must be scaling, then childing, try childing the object first.
Your answer
![](https://koobas.hobune.stream/wayback/20220613111358im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Object scale/rotation changes when parented to flipped object 0 Answers
How to instantiate an object inside parent using parent's scale 1 Answer
How to make an object's localscale values grow and shrink within a few seconds? 0 Answers
Scale gameobject around vector 0 Answers
Object's localScale 1 Answer