HierarchyMoveToParent Method |
Changes transform's parent keeping local postion, rotation and scale.
Namespace:
KSPDev.ModelUtils
Assembly:
KSPDev_Utils.1.2 (in KSPDev_Utils.1.2.dll) Version: 1.2 for KSP v1.6+
Syntaxpublic static void MoveToParent(
Transform child,
Transform parent,
Nullable<Vector3> newPosition = null,
Nullable<Quaternion> newRotation = null,
Nullable<Vector3> newScale = null
)
Request Example
View SourceParameters
- child
- Type: UnityEngineTransform
Transform to change parent for. - parent
- Type: UnityEngineTransform
Transform to change parent to. - newPosition (Optional)
- Type: SystemNullableVector3
Local position to set instead of the original one. - newRotation (Optional)
- Type: SystemNullableQuaternion
Local rotation to set instead of the original one. - newScale (Optional)
- Type: SystemNullableVector3
Local scale to set instead of the original one.
Remarks
Normally, Unity preserves world position, rotation and scale when changing parent. It's
convinient when managing objects in a prefab but is not desired when constructing a new model.
See Also