See MonoBehaviour.OnBeforeTransformParentChanged.
protected virtual void OnBeforeTransformParentChanged() { }