Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

wrong update editor window after www

Discussion in 'Immediate Mode GUI (IMGUI)' started by AlexPogodaev, Dec 26, 2014.

  1. AlexPogodaev

    AlexPogodaev

    Joined:
    Nov 20, 2014
    Posts:
    6
    Hi, when i send a request from editorwindow by www, the answer does not come until I move window.
     
  2. billykater

    billykater

    Joined:
    Mar 12, 2011
    Posts:
    329
    EditorWindows aren't constantly updated. The OnGUI function will only be called if something changes (user moves mouse over the window, you dragging the window).

    That said are you sure that the www answer is the problem here? Maybe only the window isn't redrawn so you won't see any changes. You could try to force a repaint using the Repaint() method after your data has been received.
     
  3. AlexPogodaev

    AlexPogodaev

    Joined:
    Nov 20, 2014
    Posts:
    6
    When i send www request, in consol doesn't show anything.
     
  4. AlexPogodaev

    AlexPogodaev

    Joined:
    Nov 20, 2014
    Posts:
    6
    request come just after Event.current.type == EventType.used.
     
  5. billykater

    billykater

    Joined:
    Mar 12, 2011
    Posts:
    329
    Can you show us some code on how you are receiving the www request? I am currently suspecting you are directly using the standard www coroutine pattern inside ongui.
     
  6. AlexPogodaev

    AlexPogodaev

    Joined:
    Nov 20, 2014
    Posts:
    6
    public void export(string token, string version)
    {
    string url = DOMEN + KEY_EXPORT + "?" + Time.deltaTime.ToString();
    string data = "token=" + token + "&version=" + version;
    StartCoroutine(POST(url, data, TypeConnect.export));
    }


    public IEnumerator POST(string url, string data, TypeConnect type)
    {
    byte[] rawData = Encoding.UTF8.GetBytes(data);
    WWW www = new WWW(url, rawData);
    yield return www;
    if (!String.IsNullOrEmpty(www.error))
    {
    Debug.Log(www.error);
    }
    else
    {
    switch (type)
    {
    ...
    case TypeConnect.export:
    if (!JSONHelper.parseBaseResponse(www.text))
    {
    SoftlationData.erroSyncMessage = JSONHelper.baseResponseMessage(www.text);
    Debug.Log(SoftlationData.erroSyncMessage);
    break;
    }
    //here i change my data
    SoftlationData.updateExportData(www.text);
    break;
    ...
    }
    }
    }
     
  7. billykater

    billykater

    Joined:
    Mar 12, 2011
    Posts:
    329
    Where is this code located? StartCoroutine is a method on monobehaviours so I suspect export is called on a monobehaviour sitting in the scene. By default I don't think they are properly(coroutines executing) updated while not in play mode.

    btw: use code tags. makes the code much more readable.
     
  8. AlexPogodaev

    AlexPogodaev

    Joined:
    Nov 20, 2014
    Posts:
    6
    I have EditorWindow that created two gameobject. One of them is my data, another is to create request and he is child from first. When i get response i change fisrt gameobject data and i need that data changed in my EditorWindow.
     
  9. billykater

    billykater

    Joined:
    Mar 12, 2011
    Posts:
    329
    Ok, so my current theory would be that coroutines aren't updated as long as you are not in play mode. Should be quite easy to determine.

    Some workarounds could be ExecuteInEditMode or manually rendering frames using the sceneview class. You should also be able to use WWW directly within the editorwindow without adding additional stuff to your scene by using editorwindow update and www.isDone.
     
  10. AlexPogodaev

    AlexPogodaev

    Joined:
    Nov 20, 2014
    Posts:
    6
    Thanks, but does not work. if you can, maybe you give me your skype or something else, and i show you what wrong.