Camera transformation error

Hi,

during some events I need to attach the camera to different nodes in the characters hierarchy. The camera does not need any local transformations since the parent GameObjects are transformed appropriately. The code is pretty simple:

cameraTransform.parent = mSomeCameraParent;
cameraTransform.localPosition = Vector3.zero;
cameraTransform.localRotation = Quaternion.identity;
cameraTransform.localScale = Vector3.one;

If I reposition the camera by using this code I get the following error message:

transform.rotation of 'Preview Camera' is no longer valid, due to a bad input value. Input rotation is 0.627494, -0.524879, -0.436318, 0.374675.
UnityEditor.DockArea:OnGUI()

Any ideas how to fix it? I found a similar thread http://forum.unity3d.com/threads/63630-Rotation-no-longer-working?highlight=transform.rotation+%27Preview+Camera%27+longer+valid%2C+due+bad+input+value.+Input+rotation in which it is written that closing and reopening the scene tab resp. closing Unity could solve the problem. But that did not work for my bug…

Any ideas? :\

is this fixed? i wanna know wat makes quaternion.identity to have values like 0.627494, -0.524879, -0.436318, 0.374675.

Unfortunately not solved yet… still trying to fix it.

That code in itself should work. However, the rotation that is wrong is not the localRotation but the transform.rotation, which includes the rotation of the parent. Are you sure that the parent gameObject has sane rotation values? Perhaps you are running a script on that object that contains an error, messing up the rotation for the child?