Search Unity

Emscripten-generated variables and constants in Unity 5.6

Discussion in 'Web' started by CodeBear, Dec 18, 2017.

  1. CodeBear

    CodeBear

    Joined:
    Jan 17, 2016
    Posts:
    4
    Hello - I've read the https://blogs.unity3d.com/pt/2016/12/05/unity-webgl-memory-the-unity-heap/ and am trying to implement the memory tracking but to no avail, the indicated emscriptem variables (STATICTOP, STATICBASE, DYNAMICTOP, DYNAMICBASE, etc.) no longer exist. We are trying to access them using self.instance.Module.________ which is still working for TOTAL_MEMORY, but the other variables seem to have dropped off. Is the article no longer valid or is there another way to access these fields?

    I ask specifically about 5.6 because there's a workaround in the example code for it:
    // Unity 5.6+
    return HEAP32[DYNAMICTOP_PTR >> 2] - DYNAMIC_BASE;

    In a javscript console, self.instance.Module.HEAP32 does exist, but I don't see a DYNAMICTOP_PTR value to make that actually work.

    I looked at this similar question for information but it has not been answered: https://forum.unity.com/threads/unity3d-5-6-webgl-memory-usage.464703/
     
    Last edited: Dec 18, 2017
  2. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    As of 5.6, they no longer exist in the global scope because of the new embedding system. However, you should still be able to access them via plugin (jslib) as written in the blog post. Let us know if that does not work.
     
  3. AliAnkara

    AliAnkara

    Joined:
    Dec 17, 2017
    Posts:
    7
    Hello Marco,
    Is it possible to give us an example?

    2018.2.5f1