How to refresh component such as label when the thread is busying?

How to refresh component such as label when the thread is busying?

I am doing a bit export may takes a while. During the progress I want to update the label to show the percentage, however it’s not success seems the main thread is busy and not able to update the UI. Any suggestion?
Currently I split it into several parts using actions combining with delayaction before updating the label.

maybe you need update label’s string at lateUpdate

Thank you I tried but it still freezed in the long running loop… maybe I need split the job into several parts so there are chances to update the UI…

Your question is, does the label width change immediately after the label string is changed?

@sumsumsum I guess splittig loading into several parts is the only solution. Any update to the cocos nodes happens in cocos thread, e.g. if you perform long operation like parsing spritesheet you can’t update label at the same time - you can do it before or after loading.

As a workaround you could use native UI to show your progress, for example spinning wheel which can be fully customized and users won’t notice any difference.

just tried… changing the width during the busy for-loop only takes reflect after the looping complete…

thank you. it’s okay because the long looping task only in the part of stage editor, editing progress just want let the designer know it’s loading rather than hang. Now I added 'Loading" label I think it’s enough. Just wonder any better approach or something like “DoEvents” in the old school Visual Basic haha

Which platform are you talking about?

If it’s web, there is webworker for this kind of tasks.

yes, it’s web, just my mini stage editor running a time consuming for-loop to export json.