- Create empty GameObject
- Add an imported mesh/prefab to it (a Unity primitive will do, too)
- Modify scale of parent to be non-uniform (e.g., strech or mirror one axis)
If you now modify the rotation of the child in the Inspector transform field, the mesh distorts correctly according to the non-uniform scale (note that for Unity primitives, the attached collider will not scale correctly, but that’s not the issue here).
However, if you modify the rotation any other way - either by dragging the rotation Gizmo in the Scene View, by attaching a rotation animation, or by modifying transform.localEulerAngles via script - the mesh is NOT updated correctly! It just keeps the current mesh deformation and rotates this deformed mesh locally around the selected axis. Only after modifying any of the Inspector transform fields, the mesh is recalculated and flips into the updated deformed state.
Calling mesh.RecalculateBounds() after modifying transform.localEulerAngles does not change the behaviour. Also, using transform.Rotate() or setting transform.localRotation instead of transform.localEulerAngles doesn’t help, either.
So my question is, what does the Inspector transform do differently, or more importantly, what do I need to do to correctly update the mesh after modifying its rotation?
EDIT: Some further info: The problem is still present in the current version 3.4.2f2. Also, it seems to depend on the import type/format whether a mesh shows this problem or not. After testing several imported meshes I had available, it seems that:
- the problem occurs if the mesh is a Maya .mb, Blender .blend, .fbx file, or a Unity Primitive.
- the problem does not occur if the mesh is a 3DMax .max file.
This is of course just circumstantial evidence, the actual reason whether a mesh shows this bug or not might be something else. For example, I did find a .max file where the bug occurs, 10 other .max files worked.
UPDATE:
This problem seems to be fixed for the rotation Gizmo in 3.5.x , but not for modifying the rotation via script.
I can't answer that because I don't know. This is, of course, a Unity forum. However, I would expect a Gyroscope to return more than one number - probably 3. Why not try printing to the console the values that come back and see if they are hexadecimal. If they are, then you'll need to convert using the code I've given you. You might also try going to the Ble forums and ask there.
– SurreyMuso