You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If I run (GameObjectExport).SaveToFileAndDispose I need to wrap it in try catch statements to catch any errors such as "Access to the path "xxx" is denied" (which can occur in GltfWriter->SaveToFileAndDispose on "var outStream = new FileStream(path, FileMode.Create);" for example)
(I.e. are you calling it directly or indirectly from a method like async Task Start(), async Task Awake(), i.e. an async Task of a method called by Unity instead of an async void one?)
it's called from an async void function which is called from a synchronous function.
I'm not clear why we can't just have void GoAwayAndExportOrImport(Action callback) instead of this forced async workflow which is out of sync (pun intended) with usual Unity code it seems, but to explore it:
You (certainly I) need to tell the program (as a whole) an import or export has finished, so what is the best path.
Can you have:
async void ExportSomething(GameObject obj, someDelegate result)
{
//build the GameObjectExport export;
await export.SaveToFileAndDispose(name);//run on any thread?!
result?.Invoke(success);//call on main thread
}
void StandardFunction()
{
ExportSomething(obj,delegate);
}
The async idea is kind of all or nothing, it is out of step with delegates isn't it?
I think that thread seems to show the issues with introducing async into the Unity programming world
async can be daunting at first (to me it was), but it's actually quite powerful.
I deliberately don't offer non-async overloads, as that is bad practice (according to the Microsoft Framework design guidelines, IIRC).
In this case I probably did not take good care of handling exceptions. Moreover today I fixed a bug where exports (when started from menu entries) potentially made the Editor unresponsive.
Describe the bug
If I run (GameObjectExport).SaveToFileAndDispose I need to wrap it in try catch statements to catch any errors such as "Access to the path "xxx" is denied" (which can occur in GltfWriter->SaveToFileAndDispose on "var outStream = new FileStream(path, FileMode.Create);" for example)
Not sure if this is expected or the code should catch these itself?!
The export example does not catch such exceptions so it seems wrong: https://docs.unity3d.com/Packages/[email protected]/manual/ExportRuntime.html
To Reproduce
Try to export a gltf file to a path with access denied
Expected behavior
catch exceptions in API?
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Latest 6.10
NA 2022 LTS
NA
Editor
The text was updated successfully, but these errors were encountered: