SSTUTools.SSTUModularBooster.resetTransformParents C# (CSharp) Method

resetTransformParents() private method

Utility method to -temporarily- reset the parent of the thrust transform to the parts base model transform.

This should be used before deleting a nozzle/mount model to keep the same thrust transform object in use, and the transforms should subsequently be re-parented to thier proper hierarchy after the new/updated model/module is initialized.
private resetTransformParents ( ) : void
return void
        private void resetTransformParents()
        {
            Transform modelBase = part.transform.FindRecursive("model");
            //re-parent the thrust transform so they do not get deleted when clearing the existing models
            Transform gimbal = modelBase.FindRecursive(gimbalTransformName);
            foreach (Transform tr in gimbal) { tr.parent = gimbal.parent; }
            gimbal.parent = modelBase;

            Transform thrust = modelBase.FindRecursive(thrustTransformName);
            foreach (Transform tr in thrust) { tr.parent = thrust.parent; }
            thrust.parent = modelBase;
        }