Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Feedback Awaitable feature

Discussion in '2023.1 Beta' started by dlorre, Dec 21, 2022.

  1. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    699
    I like the new Awaitable feature very much, it is specially handy with UI Toolkit. One thing I cannot do with it is to call directly from UnityEvent, so I need to encapsulate them:

    Code (csharp):
    1.  
    2.     AnalysisEvent.AddListener(analysisUpdate);
    3.  
    4.         private void analysisUpdate(AnalysisMessage am)
    5.         {
    6.             _ = analysisUpdateMT(am);
    7.         }
    8.  
    9.         private async Awaitable analysisUpdateMT(AnalysisMessage am)
    10.         {
    11.             await Awaitable.MainThreadAsync();
    12.             MainUIController.Instance.AnalysisMessage(am);
    13.         }
    14.  
    Anyway, it's still much cooler than using a script on a gameobject for main thread calls.
     
    genieMarida and TreyK-47 like this.