Skip to content
This repository has been archived by the owner on Nov 25, 2019. It is now read-only.

Implement non threaded HTTPRequest #74

Open
wilhelmberg opened this issue May 3, 2017 · 2 comments
Open

Implement non threaded HTTPRequest #74

wilhelmberg opened this issue May 3, 2017 · 2 comments
Assignees

Comments

@wilhelmberg
Copy link
Contributor

To make the Location Search widget work when Unity Editor is not playing we might need a non-threaded implementation of HTTPRequest.
Or, find a way how to get back to the main thread without the message pump being called via Update().

@david-rhodes
Copy link
Contributor

I suspect this will need to be implemented in the Unity layer.

See:

IEnumerator ValidateToken(string token)
        {
            _lastAccessToken = token;

            // TODO: implement safer url formatting?
            var www = new WWW("https://api.mapbox.com/tokens/v2?access_token=" + token);
            while (!www.isDone)
            {
                yield return 0;
            }
            var json = www.text;
            if (!string.IsNullOrEmpty(json))
            {
                ParseTokenResponse(json);
            }
        }

In MapboxConfigurationWindow.cs for an example. This worked here because the url is hardcoded and not abstracted in the cs layer. That said, I think we can just use the old HTTPRequest for editor and decide which version to delegate to in MapboxAccess.

@david-rhodes
Copy link
Contributor

Alternatively, you should be able to hook into the editor's update: http://answers.unity3d.com/questions/39313/how-do-i-get-a-callback-every-frame-in-edit-mode.html.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants