EdyJ / blender-to-unity-fbx-exporter

FBX exporter addon for Blender compatible with Unity's coordinate and scaling system.
MIT License
947 stars 98 forks source link

Blender 2.83.2 - after export script leaves temporary rotations to main scene objects #6

Closed piotradev closed 3 years ago

piotradev commented 4 years ago

Hi, I found some kind of bug in the sript. When I Export selected items theirs rotation is incremented by 90 degrees after the script finish. Looks like some temporary rotation problem. The rotations stack up every time You export. Blender 2.83.2, script 1.2 and 1.2.2

EdyJ commented 4 years ago

Can you try if the problem exists in Blender 2.82? I suspect there's some bug related with Undo in Blender 2.83, which may prevent the scene to be restored after exporting.

piotradev commented 4 years ago

2.82 was OK. I just switched to 2.83 LTS version and noticed this bug.

czw., 23 lip 2020 o 11:49 EdyJ notifications@github.com napisał(a):

Can you try if the problem exists in Blender 2.82? I suspect there's some bug related with Undo in Blender 2.83, which may prevent the scene to be restored after exporting.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/EdyJ/blender-to-unity-fbx-exporter/issues/6#issuecomment-662917072, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJ7B7HXBIUDZ47X62BCU4DR5ABTZANCNFSM4PFONBEA .

deradrian commented 3 years ago

Same here, I just update today and yes the rotation remains 90degrees after export on the objects.

piotradev commented 3 years ago

Tested 2.9 and there is the same situation. I am using a workaround with SAVE before and Revert after export. Is there any chance to fix the temporary rotation bug?

EdyJ commented 3 years ago

The addon tries to save the Undo state before modifying the objects, then restore it afterwards. How to use the Undo API is not well documented. This trick worked with Blender 2.81 and 2.82, but something seems to have changed internally in 2.83 and it doesn't work anymore.

Does pressing Undo (Ctrl-Z) after exporting fixes the scene? Maybe pressing Ctrl-Z several times? I haven't yet upgraded from 2.81, but I'm just trying to figure out possible solutions for fixing the addon.

deradrian commented 3 years ago

Sometimes Control+Z works sometimes no, in my case I just revert the scene after export.

EdyJ commented 3 years ago

I could make the addon save & revert the entire file, but I'm trying to avoid saving the file without user's consent. Sometimes you may want to export some temporary change without saving the file.

deradrian commented 3 years ago

Yup, not really a good option.

piotradev commented 3 years ago

Ctrl-Z makes objects rotate and is not going back to the original state like before export. Maybe we could use optional checkbox "save&restore" just like the "export only selected". I am so happy to use this script and wonder why not push this "Unity export" to the original code developers?

EdyJ commented 3 years ago

It had to do with how the exporter handled undo. This is mostly undocumented, but I've finally found a way where undo works properly.