Child lossyScale changes after setting localRotation

Hey there Unity community! I’ve been working quite hard on a project lately with some colleagues, and I’ve just ran into something that I think might be a Unity bug itself. Anyways, I would love you to have a look at it and tell me if I’ve stuck my foot in at any point. This is the function causing the error:

public void _Place (Transform a_parent, Vector3 a_coordinates, bool a_beKinematic = false)
				transform.parent = a_parent;
				transform.localPosition = a_coordinates;
				rigidbody.isKinematic = a_beKinematic;

				//No parent, so the pickable is dropped
				if (a_parent == null) {
						transform.localEulerAngles = DropRotation;
				} else {//Parented, so the pickable is equipped
						transform.localEulerAngles = EquipRotation;

The point of the function is to parent / unparent the gameObject with this script attached to the one passed as a parameter. Because of some weird reason, when transform.localEulerAngles = EquipRotation happens (IE, the object has just been parented), the child (the gameObject running the script) changes its scale both numerically (which would make sense, given the fact that it has just been parented by an object with a scale different from (1,1,1)), AND graphically. This is, not only does it apply the localScale it should apply when being parented, but it also changes its global scale when set its localEulerAngles property.

This happens for setting both localEulerAngles and localRotation. If I comment out that line, everything works fine. I’m going nuts. Can somebody help me out?

Thanks beforehand

I am running into this problem as well, and unfortunately I have not yet found a solution that I find ideal. I’ve been searching the forums trying to find a calculation or algorithm to reverse this.

Basically what is happening, is the transform of the gameObject becomes parented to something scaled non-uniformly and the rotation does not match which causes it to skew (scale is stored in 4 values, but the 4th is not visible/editable kind of like quaternions which accounts for the skew).

So the options I have seen to avoid this are to have the parent scaled uniformly (all the axes scaled the same), have the child and parent match their rotations, or have an intermediate empty game object with scale of (1,1,1) in between what is currently the parent and the child.

Good luck, and I hope that one of these will help you out!