/// <summary> /// Set the position and rotation of a Transform as if its origin were that of 'anchor'. /// Anchor should be local to the Transform where <0,0,0> would be the same as its true origin. /// </summary> /// <param name="trans">The transform to transpose.</param> /// <param name="anchor">The point around which to transpose in world space.</param> /// <param name="position">The new position in world space.</param> /// <param name="rotation">The new rotation in world space.</param> public static void TransposeAroundAnchor(this Transform trans, Transform anchor, Vector3 position, Quaternion rotation) { if (trans.parent != null) { position = trans.parent.InverseTransformPoint(position); rotation = trans.parent.InverseTransformRotation(rotation); } LocalTransposeAroundAnchor(trans, anchor.ToRelativeTrans(trans), position, rotation); }