Skip to content
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

xxxxxxx can only be called from the main thread. #25

Open
ronaldovelo opened this issue Apr 24, 2018 · 1 comment
Open

xxxxxxx can only be called from the main thread. #25

ronaldovelo opened this issue Apr 24, 2018 · 1 comment

Comments

@ronaldovelo
Copy link

I started today using your socket-io asset, and I have been trying to understand the problem, I did understand in fact, but I dont know how to work-arround.

This is the event

socket.On("CLIENT_SUCCESSFUL_LOGIN", (data) =>
            {
                string dataS = data.ToString();
                Dictionary<string, string> values = JsonConvert.DeserializeObject<Dictionary<string, string>>(dataS);
                string _userID = values["userId"];
                float _funds = float.Parse(values["funds"]);
                SuccessfulLogin(_userID, _funds);
            });

And I want execute a function and it gives me that error...

void SuccessfulLogin(string _userId, float _funds)
    {
        unlockedItems.Clear();
        userId = _userId;
        funds = _funds;
        isLogged = true;
        menuManager.ChooseMenu(1);
    }
public void ChooseMenu(int menuId)
    {
        if (menuId < menuPanels.Count && menuId >= 0)
        {
            DisableCanvasGroup(menuPanels[activePanel].GetComponent<CanvasGroup>());
            EnableCanvasGroup(menuPanels[menuId].GetComponent<CanvasGroup>());
            activePanel = menuId;
            UpdateFields();
        }
    }
@Zbluu
Copy link

Zbluu commented May 8, 2018

This is not a issue relative to this asset.

https://stackoverflow.com/questions/41330771/use-unity-api-from-another-thread-or-call-a-function-in-the-main-thread

I use the solution of the first answer, it's works.

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

No branches or pull requests

2 participants