Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Enabling embedded resources with WebGL

Discussion in 'Web' started by JoshPeterson, May 15, 2015.

  1. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    As of Unity version 5.0.2p1 (available here), the IL2CPP scripting backend now supports embedded resources. The version of mscorlib.dll shipping with Unity now contains some embedded resources used for a few localization API calls. These embedded resources add about 330 KB of data (uncompressed) to the build output.

    We decided not to enable embedded resources by default for WebGL builds, so that we could avoid this extra size. They can be enabled using the following editor script:

    Code (CSharp):
    1. using UnityEditor;
    2. public class WebGLEditorScript
    3. {
    4.     [MenuItem("WebGL/Enable Embedded Resources")]
    5.     public static void EnableErrorMessageTesting()
    6.     {
    7.         PlayerSettings.SetPropertyBool("useEmbeddedResources", true, BuildTargetGroup.WebGL);
    8.     }
    9. }
     
    doanlinhit24 likes this.
  2. bsterling250DI

    bsterling250DI

    Joined:
    Sep 25, 2014
    Posts:
    78
    what does "embeddedResources" refer to? Just these localization api calls you mentioned? or is it something we can use?
     
  3. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    @bsterling250DI

    An embedded resource is data which can be written into a managed assembly, then read back out latter. It is a general tool, which is not specific to localization. You can see a few more details from MSDN here. For the mscorlib.dll with Mono, embedded resources happen to be used for localization only, but you can add embedded resources for any purpose to an assembly.

    If you do choose to use embedded resources with WebGL though, make sure that you us the editor script (or something similar) above, as the IL2CPP scripting backend will otherwise ignore the embedded resources.
     
  4. Nostra2207

    Nostra2207

    Joined:
    Aug 20, 2014
    Posts:
    3
    Hi,
    Did it work the same for iOS? Because i work on a project with the iTextSharp dll which contains some embedded resources and it works when i build for arm7 without il2cpp. But when i switch to arm64 and il2cpp resources are not found.

    I use Unity 4.6.6 p4 and Xcode 6.3.2.
    Sorry for my bad english and have a nice day.
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    @Nostra2207

    Embedded resources should work for iOS builds by default. There is no need to run a special editor script. If this is not working, it is a bug, so could you please submit a bug report? We would love to correct it! Thanks.
     
  6. Nostra2207

    Nostra2207

    Joined:
    Aug 20, 2014
    Posts:
    3
    @JoshPeterson

    I tried several things but when i build for arm64, i can't access resources whether my class are inside or outside the dll . I maybe missing something, Is there a particular way of importing the dll or to load these resources manually to get it work. I will submit a bug report with the test project i use.
     
  7. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    @Nostra2207

    You should not have to do anything special to make embedded resources work for an iOS build. If they work with the Mono scripting backend, they should work with IL2CPP as well. Please let me know the bug report number when you submit it, and we will have a look at it. Thanks!
     
  8. Nostra2207

    Nostra2207

    Joined:
    Aug 20, 2014
    Posts:
    3
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    @Nostra2207

    Thanks, we will investigate this one.
     
  10. Ryuuguu

    Ryuuguu

    Joined:
    Apr 14, 2007
    Posts:
    394
    does embedded resources refer to resources loaded such as Resources.Load<TextAsset>("FixedData") ?
     
  11. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
  12. doanlinhit24

    doanlinhit24

    Joined:
    Mar 17, 2016
    Posts:
    2
    Last edited: Mar 12, 2019