GithubHelp home page GithubHelp logo

Comments (10)

SolarianZ avatar SolarianZ commented on August 22, 2024

Android和Unity都不允许在非主线程操作UI吧

from uiwidgets.

Latias94 avatar Latias94 commented on August 22, 2024

Android和Unity都不允许在非主线程操作UI吧

在回调中写应该没问题吧?那应该怎么改呢?

from uiwidgets.

kgdev avatar kgdev commented on August 22, 2024

嗯嗯 首先你要打开debug模式, 然后会有相应的提示信息给到你.

Define UIWidgets_DEBUG
It's recommended to define the UIWidgets_DEBUG script symbol in editor, this will turn on debug assertion in UIWidgets, which will help to find potential bugs earlier. To do this: please go to Player Settings -> Other Settings -> Configuration -> Scripting Define Symbols, and add UIWidgets_DEBUG.
The symbol is for debug purpose, please remove it from your release build.

from uiwidgets.

Latias94 avatar Latias94 commented on August 22, 2024

嗯嗯 首先你要打开debug模式, 然后会有相应的提示信息给到你.

Define UIWidgets_DEBUG
It's recommended to define the UIWidgets_DEBUG script symbol in editor, this will turn on debug assertion in UIWidgets, which will help to find potential bugs earlier. To do this: please go to Player Settings -> Other Settings -> Configuration -> Scripting Define Symbols, and add UIWidgets_DEBUG.
The symbol is for debug purpose, please remove it from your release build.

你好,上面的报错就是加了 UIWidgets_DEBUG 后的报错信息,想问问有没有网络请求的 sample 供参考呢?

from uiwidgets.

kgdev avatar kgdev commented on August 22, 2024

Try to use "using (WindowProvider.of(BuildContext).getScope()) { ... }" to wrap your code.

BuildContext 如果在widget里面就是this.context.

from uiwidgets.

SolarianZ avatar SolarianZ commented on August 22, 2024

Android和Unity都不允许在非主线程操作UI吧

在回调中写应该没问题吧?那应该怎么改呢?

你的回调方法是在主线程里面声明的,但是它的调用是在异步线程中调用的,所以他还是在异步中执行的。应该在主线程中写一个调用队列,异步完成时把回调塞到队列里,然后主线程一直检测队列中是否有要执行的回调,如果有,就执行,这样UI操作就回到主线程执行了。

from uiwidgets.

Latias94 avatar Latias94 commented on August 22, 2024

Try to use "using (WindowProvider.of(BuildContext).getScope()) { ... }" to wrap your code.

BuildContext 如果在widget里面就是this.context.

Solved!
Thanks for your quick response, May I ask if there has a communication group for testing UIWidgets?

from uiwidgets.

kgdev avatar kgdev commented on August 22, 2024

https://connect.unity.com/u/kevin-gu

Add me as a friend and I will add you to our wechat group.

from uiwidgets.

qingbaomeng avatar qingbaomeng commented on August 22, 2024

@Latias94 using (WindowProvider.of(BuildContext).getScope()) { ... }
你是用这个方案解决的吗?

from uiwidgets.

Latias94 avatar Latias94 commented on August 22, 2024

@Latias94 using (WindowProvider.of(BuildContext).getScope()) { ... }
你是用这个方案解决的吗?

你好,我忘了... 不过你可以参考下两个官方开源应用的做法:
https://github.com/UnityTech/ConnectAppCN
https://github.com/UnityTech/DocCN

from uiwidgets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.