Child object reset to parent transform?

In the editor it is easy to reset a child object's transform so that it matches the parent's but is there an easy way to do this in code? I am using the long way:

transform.rotation = parent.transform.rotation;
transform.localPosition = Vector3(0,0,0);
transform.localScale = Vector3(1,1,1);

Is there a shorter (one line) way?

Use this

Another little improvement ;)

    transform.localRotation = Quaternion.identity;
    transform.localPosition =;
    transform.localScale =;

both Transform.rotation and Transform.position are special properties that automatically convert the world position into local position. That's why it's better to set the local position or rotation at least in such a case.

There is no way to set the global scale. Unity just offers a readonly lossyScale to get the resulting scale in world space. (Setting the scale in world space would be a pain to transform the scale through all parents (rotation, position, scale) and would be prone to fail due to inaccuracy of floating point values

No, I think your 3 line-way is already pretty much the best you can do. I could think of one potential little improvement:

transform.rotation = parent.transform.rotation;
transform.localPosition =;
transform.localScale =;

As Vector3 is a struct this probably won't really make much of a difference as structs are by value and not by reference (if it was a by-reference type this would spare you two objects which later might have to be garbage collected). Nevertheless, I think it's good programming practice to use such "standard objects" for "standard cases".