Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

TextMesh Pro WebGL & .Net 4.6

Discussion in 'Unity UI & TextMesh Pro' started by Sgrueling, Nov 15, 2017.

  1. Sgrueling

    Sgrueling

    Joined:
    Nov 7, 2016
    Posts:
    11
    Hello,

    I just would request an update regarding the situation with TextMeshPro, WebGL and .net 4.6.
    Currently it throws this exception when I build a WebGL Version.

    Code (CSharp):
    1. Rethrow as TypeInitializationException: The type initializer for 'System.Globalization.CharUnicodeInfo' threw an exception.
    It's reported in this Issue: https://issuetracker.unity3d.com/is...doperationexception-on-webgl-with-net-4-dot-6

    Last post regarding this was: https://forum.unity.com/threads/tex...ed-text-rendering.248636/page-40#post-3162858

    Is there anyway to work around this? Is there a fix on the way?
    Any update?

    Regards,
    Shane
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,734
    In what version of Unity are you getting this error?

    As you may already know, this issue is exposed by TMP but not specific to it. I thought it had been addressed but let me see if I can track down those who would be looking into this.
     
  3. Sgrueling

    Sgrueling

    Joined:
    Nov 7, 2016
    Posts:
    11
    Tried it today in 2017.2.0p1 but i have it since it's .net 4.6 is available.

    Thanks already for the quick answer! :)
     
  4. Sgrueling

    Sgrueling

    Joined:
    Nov 7, 2016
    Posts:
    11
    *bump*

    Found anyone? ;)
     
  5. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,734
    The team handling .Net 4.6 is aware of the issue but no ETA on a fix yet.
     
  6. Sgrueling

    Sgrueling

    Joined:
    Nov 7, 2016
    Posts:
    11
    Thanks!
     
  7. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    532
    Running into this in 2018.1. Was there any final resolution or workaround here?
     
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    3,381
    @Claytonious

    Are you enabling embedded resources for WebGL? This issue only happens when IL2CPP tries to load the embedded resources in the mscorlib.dll assembly on WebGL with the .NET 4.x scripting runtime. By default, embedded resources are not enabled for WebGL (to save build size).

    So if you don't need embedded resources and have them enabled, I would recommend disabling them. That should work around this issue.
     
  9. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    532
    No, we are NOT building with embedded resources. This is a fairly "vanilla" setup. Just having a TextMeshPro input field in WebGL with net standard 2.0 scripting seems to cause this exception.

    Should I try building WITH embedded resources? (Sounds like you are saying the opposite, but I want to make sure).
     
  10. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    3,381
    Yes, I'm saying you should not build with embedded resources. I'm surprised to see this happening without embedded resources enabled. I may not fully understand your situation. In any case, we have a fix on the way for this issue. It should be in a 2018.1 patch release soon.
     
  11. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    3,381
    I've thoroughly confused this issue, sorry about that. I thought this was a different problem - I did not go back and look at the original bug report.

    So, to correct this, you should build for WebGL with embedded resources enabled. Please ignore my previous comments, they were about a different issue.
     
    Claytonious likes this.
  12. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    532
    Got it. Will let you know how it goes. Thank you!
     
  13. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    532
    Unfortunately, even building with embedded resources did not fix the problem. Setting the text on any TextMeshProInputField in a WebGL build still leads to:

    Code (CSharp):
    1. System.TypeInitializationException: The type initializer for 'System.Globalization.CharUnicodeInfo' threw an exception. ---> System.InvalidOperationException: Operation is not valid due to the current state of the object.
    2.   at System.Globalization.GlobalizationAssembly.GetGlobalizationResourceBytePtr (System.Reflection.Assembly assembly, System.String tableName) [0x00000] in <00000000000000000000000000000000>:0
    3.   at System.Globalization.CharUnicodeInfo.InitTable () [0x00000] in <00000000000000000000000000000000>:0
    4.   at System.Globalization.CharUnicodeInfo..cctor () [0x00000] in <00000000000000000000000000000000>:0
    5.   at System.Char.IsWhiteSpace (System.Char c) [0x00000] in <00000000000000000000000000000000>:0
    6.   at TMPro.TextMeshProUGUI.SetArraySizes (System.Int32[] chars) [0x00000] in <00000000000000000000000000000000>:0
    7.   at TMPro.TMP_Text.ParseInputText () [0x00000] in <00000000000000000000000000000000>:0
    8.   at TMPro.TMP_Text.GetPreferredHeight () [0x00000] in <00000000000000000000000000000000>:0
    9.   at TMPro.TMP_Text.get_preferredHeight () [0x00000] in <00000000000000000000000000000000>:0
    10.   at TMPro.TMP_InputField.AdjustTextPositionRelativeToViewport (System.Single relativePosition) [0x00000] in <00000000000000000000000000000000>:0
    11.   at TMPro.TMP_InputField.set_text (System.String value) [0x00000] in <00000000000000000000000000000000>:0
    I built with embedded resources by doing this:

    Code (CSharp):
    1.     public class WebGlBuilder : IProcessSceneWithReport
    2.     {
    3.         private static bool _hasSetup;
    4.         public int callbackOrder => 0;
    5.        
    6.         public void OnProcessScene(Scene scene, BuildReport report)
    7.         {
    8.             if (!_hasSetup)
    9.             {
    10.                 _hasSetup = true;
    11. #pragma warning disable 0618
    12.                 PlayerSettings.SetPropertyBool("useEmbeddedResources", true, BuildTargetGroup.WebGL);
    13. #pragma warning restore 0618
    14.             }          
    15.         }
    16.     }
    17.  
     
  14. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    532
    I spoke too soon! Apparently, setting the flag in an implementation of IProcessSceneWithReport had no effect. By just manually executing this from a menu item and then saving the project, THEN rebuilding, this did, in fact, fix the problem.

    Thank you for your help @JoshPeterson. Needless to say, this will be a roadblock for other users but it sounds like you're fixing it "out of the box" for a future release already.
     
  15. Gigacee

    Gigacee

    Joined:
    Mar 4, 2015
    Posts:
    6
    Same error in Unity 2018.1.0f2 and .Net 4.x. I can't use TextMeshProUGUI on WebGL because of this error.

    Code (CSharp):
    1. InvalidOperationException: Operation is not valid due to the current state of the object.
    2. at System.Globalization.GlobalizationAssembly.GetGlobalizationResourceBytePtr (System.Reflection.Assembly assembly, System.String tableName) [0x00000] in <00000000000000000000000000000000>:0
    3. Rethrow as TypeInitializationException: The type initializer for 'System.Globalization.CharUnicodeInfo' threw an exception.
    4.  
    5. (Filename: currently not available on il2cpp Line: -1)
    Incomprehensibly, TextMeshPro (not in Canvas) is work correctly.
    And TextMeshProUGUI with only alphanumeric characters is work correctly too.
    I use TextMeshProUGUI and Japanese in my Game and some of them break.
     
  16. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    532
    Did you build with embedded resources?
     
  17. Gigacee

    Gigacee

    Joined:
    Mar 4, 2015
    Posts:
    6
    Sorry, I didn't build with embedded resources enabled because I didn't know how to do it.

    I examined again today and I could do it by following script:

    Code (CSharp):
    1. using UnityEditor;
    2.  
    3. public class WebGLEditorScript
    4. {
    5.     [MenuItem("Tools/WebGL/Enable Embedded Resources")]
    6.     public static void EnableEmbeddedResources()
    7.     {
    8.         PlayerSettings.WebGL.useEmbeddedResources = true;
    9.     }
    10. }
    11.  
    And then, TextMeshProUGUI was working fine in .Net 4.x. Thank you!
     
    Aurigan, JoshPeterson and Stephan_B like this.
  18. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,734
  19. Cypras

    Cypras

    Joined:
    Oct 25, 2013
    Posts:
    50
    @JoshPeterson

    I'm having this error here:

    Code (CSharp):
    1. IOException: Sharing violation on path C:\Users\joshe\Desktop\TT\UpDunks2 - Copy (3)\UpDunks\Temp\StagingArea\assets\bin\Data\Managed\tempStrip\TextMeshPro-2017.2-1.0.56-Runtime.dll
    2. System.IO.File.Move (System.String sourceFileName, System.String destFileName) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/File.cs:339)
    3. UnityEditorInternal.AssemblyStripper.RunAssemblyStripper (System.String stagingAreaData, IEnumerable assemblies, System.String managedAssemblyFolderPath, System.String[] assembliesToStrip, System.String[] searchDirs, System.String monoLinkerPath, IIl2CppPlatformProvider platformProvider, UnityEditor.RuntimeClassRegistry rcr) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:256)
    4. UnityEditorInternal.AssemblyStripper.StripAssemblies (System.String stagingAreaData, IIl2CppPlatformProvider platformProvider, UnityEditor.RuntimeClassRegistry rcr) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:114)
    5. UnityEditorInternal.IL2CPPBuilder.Run () (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:143)
    6. UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String tempFolder, System.String stagingAreaData, IIl2CppPlatformProvider platformProvider, System.Action`1 modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry, Boolean debugBuild) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:34)
    7. UnityEditor.Android.PostProcessor.Tasks.RunIl2Cpp.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    8. UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    9. UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.BuildReporting.BuildReport report)
    10. UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (BuildPostProcessArgs args)
    11. UnityEditor.PostprocessBuildPlayer.Postprocess (BuildTargetGroup targetGroup, BuildTarget target, System.String installPath, System.String companyName, System.String productName, Int32 width, Int32 height, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.BuildReporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:271)
    12. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    13.  
    I've done the use embedded resources and it solved the issue for 2-3 builds, but now it doesn't work regardless.

    I'm using Unity 2017.2.1, IL2CPP Android Build. Sometimes a similar error shows up but mentions Dotween instead of TextMeshPro.

    Any ideas?

    @Stephan_B mentioned to ask you.

    Thanks
     
  20. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    3,381
  21. Cypras

    Cypras

    Joined:
    Oct 25, 2013
    Posts:
    50
    So here is the error i'm getting:
    Code (CSharp):
    1. IOException: Sharing violation on path C:\Users\joshe\Desktop\TT\UpDunks2 - Copy (3)\UpDunks\Temp\StagingArea\assets\bin\Data\Managed\tempStrip\TextMeshPro-2017.2-1.0.56-Runtime.dll
    2. System.IO.File.Move (System.String sourceFileName, System.String destFileName) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/File.cs:339)
    3. UnityEditorInternal.AssemblyStripper.RunAssemblyStripper (System.String stagingAreaData, IEnumerable assemblies, System.String managedAssemblyFolderPath, System.String[] assembliesToStrip, System.String[] searchDirs, System.String monoLinkerPath, IIl2CppPlatformProvider platformProvider, UnityEditor.RuntimeClassRegistry rcr) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:256)
    4. UnityEditorInternal.AssemblyStripper.StripAssemblies (System.String stagingAreaData, IIl2CppPlatformProvider platformProvider, UnityEditor.RuntimeClassRegistry rcr) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:114)
    5. UnityEditorInternal.IL2CPPBuilder.Run () (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:143)
    6. UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String tempFolder, System.String stagingAreaData, IIl2CppPlatformProvider platformProvider, System.Action`1 modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry, Boolean debugBuild) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:34)
    7. UnityEditor.Android.PostProcessor.Tasks.RunIl2Cpp.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    8. UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    9. UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.BuildReporting.BuildReport report)
    10. UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (BuildPostProcessArgs args)
    11. UnityEditor.PostprocessBuildPlayer.Postprocess (BuildTargetGroup targetGroup, BuildTarget target, System.String installPath, System.String companyName, System.String productName, Int32 width, Int32 height, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.BuildReporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:271)
    12. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    13.  
    And after I get this error, I do a search using Process Explorer and search for 'TextMeshPro' and 'TextMeshPro-2017.2-1.0.56-Runtime.dll' both of which return 0 results.

    Did I do something wrong?

    Thanks.

    @JoshPeterson
     
  22. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    3,381
    @Cypras

    I think you did everything correctly. I'm unsure about the cause of the issue then. Is it possible for you to try a newer version of Unity? I don't think this is an issue we have corrected, but maybe it was.