Replies: 2 comments 2 replies
-
I get that a new concept like However, the import/export processes of glTFast are inherently async and using it makes a lot of sense (both from performance and maintainability). I followed the Microsoft Framework Design Guidelines and do not offer sync variants of any API method. One can invoke a glTFast process from a sync context in a fire-and-forget. However, that has implications on how error handling has to happen and, as you figured, awaiting the result becomes harder. I recommend all devs to invest the time and invoke glTFast methods from async methods only. hth |
Beta Was this translation helpful? Give feedback.
-
It is a change of thinking which some people are having trouble with using async in Unity. void Update()
{
//do some game/app logic
//detect something has triggered a need to load a glb model!!
//start off coroutine to load it (but it is async so call an async void function that awaits a Task?)
//finish update logic for game/app
}
async void LoadBinaryModel(...)
{
bool success = await import.LoadGltfBinary(...)
//send a mesage/delegate etc.
} |
Beta Was this translation helpful? Give feedback.
-
(Runtime use) I see that all non async use has been deprecated which makes sense, however... it is interesting that this API uses Task which I have not personally seen used anywhere else in Unity code or packages. There is a big hole in my C# knowledge around Tasks (hopefully the only hole!). All the examples tend to use a new monobehaviour with an async Start() method or just start from an async call but consider examples starting from a non-async method and what if you want a delegate on completion of loading say?
Beta Was this translation helpful? Give feedback.
All reactions