Click or drag to resize

HierarchyMoveToParent Method

Changes transform's parent keeping local postion, rotation and scale.

Namespace:  KSPDev.ModelUtils
Assembly:  KSPDev_Utils.2.0 (in KSPDev_Utils.2.0.dll) Version: 2.0 for KSP v1.8+
Syntax
C#
public static void MoveToParent(
	Transform child,
	Transform parent,
	Nullable<Vector3> newPosition = null,
	Nullable<Quaternion> newRotation = null,
	Nullable<Vector3> newScale = null
)
Request Example View Source

Parameters

child
Type: Transform
Transform to change parent for.
parent
Type: Transform
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