Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Enabling embedded resources with WebGL

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

  1. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,735
    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,735
    @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,735
    @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,735
    @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,735
    @Nostra2207

    Thanks, we will investigate this one.
     
  10. Ryuuguu

    Ryuuguu

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

    JoshPeterson

    Unity Technologies

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

    doanlinhit24

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