Skip to content

Best Practices for Realtime UI updates in Unity #126

Answered by wiverson
GrimLothar asked this question in Q&A
Discussion options

You must be logged in to vote

Yeah, it's a PITA.

Here's the basic pattern for what I wind up doing. Let's say the thing I'm interested in is messages from the server. So I'd have a var incoming = new List in my MonoBehavior. Then I add messages to this List via the channel updates. Then I have an Update() method that looks for messages and removes them, which is fine as Update always runs on the UI thread. I use UniTask to make sure the async/await is managed properly WRT to setting up the context.

I like your version as well, it's probably more technically accurate but I think it's basically doing the same thing WRT setting up the sync context as UniTask & Update.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@acupofjose
Comment options

@wiverson
Comment options

Answer selected by GrimLothar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants