Click or drag to resize

HierarchyMoveToParent Method

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

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

Parameters

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