-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Callbacks not on Main Thread issue #9
Comments
Obs: I have just noticed that you do mention that the callbacks are not on (Unity's) main thread... but who reads documents? :) Just kidding, but anyhow if you could somehow make it run on Unity's main thread it would be much better |
I think you can do it by yourself. public IEnumerator MyPermissionRequestCoroutine(string permission, Action grantedPermission, Action deniedPermission ){
bool granted = false;
bool gotCallback = false;
AndroidPermissionsManager.RequestPermission(new string[] { permission },
new AndroidPermissionCallback(
grantedPermission =>
{
gotCallback = true;
granted = true;
},
deniedPermission =>
{
gotCallback = true;
granted = false;
}
));
while (gotCallback == false)
yield return null;
if (granted)
{
grantedPermission();
}
else
{
deniedPermission();
}
}
//and use
StartCoroutine(MyPermissionRequestCoroutine( ... )); (written from head) |
Thanks for the suggestion. I had already made a solution similar to this, using flags. But anyway it would be best for the user of the plugin if the callback was already on the main thread, so he didnt need to do anything (or lose time with crashes not noticing the callback isn't on the main thread). |
Context synchronization should be used for this indeed. |
I have integrated your plugin and it's working great - thanks!
But I have one problem/suggestion: make the callbacks run on main thread.
I was having a lot of problems until I found out the callbacks weren't on the main thread.
I had to turn on a flag on the callback and then check for the flag on the next Update. No big deal, but it would be better if the callback was already on the main thread, or at least make it clear for the developer that the callbacks are not on the main thread.
Best
The text was updated successfully, but these errors were encountered: