Answered

How to set export settings via script

mb1 2 years ago updated by Peter - Soxware Developer 2 years ago 3

I have UMotion Pro and need to export many animations with some modifications, the workflow I'm hoping for is:

Via script:

1. import a clip

2. change export settings to reference a different output FBX file

3. (some pose work)

4. export the clip

I know #4 (export) is possible with the API, but how do I do #1 and #2? 

Much thanks!

UMotion Version:
latest pro
Unity Version:
2021.3.8f1

Answer

Answer
Answered

Hi,
thank you very much for your support request.

Unfortunately there is currently no way to access the export settings via the UMotion API. Some hacky workaround would be to close the UMotion project file, call AssetDatabase.SaveAssets() to ensure all changes are serialized to disc, then directly modify the settings in the UMotion project file via default .Net file IO, reload with AssetDatabase.Reload() and then open the UMotion project file again via UMotion API.


Please let me know in case you have any follow-up questions.

Best regards,
Peter

Answer
Answered

Hi,
thank you very much for your support request.

Unfortunately there is currently no way to access the export settings via the UMotion API. Some hacky workaround would be to close the UMotion project file, call AssetDatabase.SaveAssets() to ensure all changes are serialized to disc, then directly modify the settings in the UMotion project file via default .Net file IO, reload with AssetDatabase.Reload() and then open the UMotion project file again via UMotion API.


Please let me know in case you have any follow-up questions.

Best regards,
Peter

So for the hacky way, in the UMotionProject YAML asset file, I just need to change MonoBehaviour::Settings::ExportDestinationPath::valueInternal to point at the desired FBX output file and that's it?

Full steps to confirm:

1. ClipEditorAPI CloseProject

2. AssetDatabase.SaveAssets()

3. MonoBehaviour::Settings::ExportDestinationPath::valueInternal to point at the desired FBX output file and that's it?

4. ClipEditor API: LoadProject

5. PoseEditor API: SetAnimatedGameObject
6. ClipEditor API ImportClips and SelectClip

7. ClipEditor API ExportCurrentClip

(repeat)

If that's it, that would be just fine

Between step 3 and 4 you need to call AssetDatabase.Reload() so that the changes you've made to the yaml file are loaded by Unity. Other than that, I think this should work (but I haven't tested this myself).


Let me know if you run into troubles.


Best regards,
Peter