I created a new project in 2020.1.17f1 (also replicated in 2020.2.1f1) with UIBuilder 11 and UIToolkit 13. If I try creating a Label in the UIBuilder with text wrap on, and then set the text to something in Japanese, then errors repeatedly appear in the console in either CalculatePreferredValues or GenerateTextMesh. If I set the text to something in English and then change it at runtime into Japanese, the same errors appear.
Everything works if the text wrap is set to nowrap.
It seems to be due to the properties leadingCharactersLookup/followingCharactersLookup
not being set, which should correspond to the “Line Breaking for Asian languages” option in the Panel Text Settings, but setting these does not change anything.
I was using UIBuilder 9 and UIToolkit 9 before, and those versions worked.
The stack trace looks like this.
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.TextCore.Text.TextGenerator.CalculatePreferredValues (System.Single defaultFontSize, UnityEngine.Vector2 marginSize, System.Boolean ignoreTextAutoSizing, UnityEngine.TextCore.Text.TextGenerationSettings generationSettings, UnityEngine.TextCore.Text.TextInfo textInfo) (at Library/PackageCache/com.unity.textcore@1.0.0-preview.2/Scripts/Runtime/TextGenerator.cs:5813)
UnityEngine.TextCore.Text.TextGenerator.GetPreferredValuesInternal (UnityEngine.TextCore.Text.TextGenerationSettings generationSettings, UnityEngine.TextCore.Text.TextInfo textInfo) (at Library/PackageCache/com.unity.textcore@1.0.0-preview.2/Scripts/Runtime/TextGenerator.cs:5253)
UnityEngine.TextCore.Text.TextGenerator.GetPreferredValues (UnityEngine.TextCore.Text.TextGenerationSettings settings, UnityEngine.TextCore.Text.TextInfo textInfo) (at Library/PackageCache/com.unity.textcore@1.0.0-preview.2/Scripts/Runtime/TextGenerator.cs:400)
UnityEngine.UIElements.Text.TextCoreHandle.UpdatePreferredValues (UnityEngine.UIElements.MeshGenerationContextUtils+TextParams parms) (at Library/PackageCache/com.unity.ui@1.0.0-preview.13/Text/TextCoreHandle.cs:177)
UnityEngine.UIElements.Text.TextCoreHandle.ComputeTextHeight (UnityEngine.UIElements.MeshGenerationContextUtils+TextParams parms, System.Single scaling) (at Library/PackageCache/com.unity.ui@1.0.0-preview.13/Text/TextCoreHandle.cs:88)
UnityEngine.UIElements.TextUtilities.MeasureVisualElementTextSize (UnityEngine.UIElements.VisualElement ve, System.String textToMeasure, System.Single width, UnityEngine.UIElements.VisualElement+MeasureMode widthMode, System.Single height, UnityEngine.UIElements.VisualElement+MeasureMode heightMode, UnityEngine.UIElements.ITextHandle textHandle) (at Library/PackageCache/com.unity.ui@1.0.0-preview.13/Core/Text/TextHandle.cs:400)
UnityEngine.UIElements.TextElement.MeasureTextSize (System.String textToMeasure, System.Single width, UnityEngine.UIElements.VisualElement+MeasureMode widthMode, System.Single height, UnityEngine.UIElements.VisualElement+MeasureMode heightMode) (at Library/PackageCache/com.unity.ui@1.0.0-preview.13/Core/TextElement.cs:320)
UnityEngine.UIElements.TextElement.DoMeasure (System.Single desiredWidth, UnityEngine.UIElements.VisualElement+MeasureMode widthMode, System.Single desiredHeight, UnityEngine.UIElements.VisualElement+MeasureMode heightMode) (at Library/PackageCache/com.unity.ui@1.0.0-preview.13/Core/TextElement.cs:335)
UnityEngine.UIElements.VisualElement.Measure (UnityEngine.Yoga.YogaNode node, System.Single width, UnityEngine.Yoga.YogaMeasureMode widthMode, System.Single height, UnityEngine.Yoga.YogaMeasureMode heightMode) (at Library/PackageCache/com.unity.ui@1.0.0-preview.13/Core/VisualElement.cs:1532)
UnityEngine.UIElements.VisualElement.<AssignMeasureFunction>b__335_0 (UnityEngine.Yoga.YogaNode node, System.Single f, UnityEngine.Yoga.YogaMeasureMode mode, System.Single f1, UnityEngine.Yoga.YogaMeasureMode heightMode) (at Library/PackageCache/com.unity.ui@1.0.0-preview.13/Core/VisualElement.cs:1516)
UnityEngine.Yoga.YogaNode.MeasureInternal (UnityEngine.Yoga.YogaNode node, System.Single width, UnityEngine.Yoga.YogaMeasureMode widthMode, System.Single height, UnityEngine.Yoga.YogaMeasureMode heightMode) (at <a60568d854ce4242b925658dfd58b04f>:0)
UnityEngine.Yoga.Native.YGNodeMeasureInvoke (UnityEngine.Yoga.YogaNode node, System.Single width, UnityEngine.Yoga.YogaMeasureMode widthMode, System.Single height, UnityEngine.Yoga.YogaMeasureMode heightMode, System.IntPtr returnValueAddress) (at <a60568d854ce4242b925658dfd58b04f>:0)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
Or alternatively
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.TextCore.Text.TextGenerator.GenerateTextMesh (UnityEngine.TextCore.Text.TextGenerationSettings generationSettings, UnityEngine.TextCore.Text.TextInfo textInfo) (at Library/PackageCache/com.unity.textcore@1.0.0-preview.2/Scripts/Runtime/TextGenerator.cs:1694)
UnityEngine.TextCore.Text.TextGenerator.GenerateText (UnityEngine.TextCore.Text.TextGenerationSettings settings, UnityEngine.TextCore.Text.TextInfo textInfo) (at Library/PackageCache/com.unity.textcore@1.0.0-preview.2/Scripts/Runtime/TextGenerator.cs:315)
UnityEngine.UIElements.Text.TextCoreHandle.Update (UnityEngine.UIElements.MeshGenerationContextUtils+TextParams parms, System.Single pixelsPerPoint) (at Library/PackageCache/com.unity.ui@1.0.0-preview.13/Text/TextCoreHandle.cs:134)
UnityEngine.UIElements.UIR.Implementation.UIRStylePainter.DrawTextCore (UnityEngine.UIElements.MeshGenerationContextUtils+TextParams textParams, UnityEngine.UIElements.ITextHandle handle, System.Single pixelsPerPoint) (at Library/PackageCache/com.unity.ui@1.0.0-preview.13/Core/Renderer/UIRStylePainter.cs:389)
UnityEngine.UIElements.Text.TextCoreHandle.DrawText (UnityEngine.UIElements.UIR.Implementation.UIRStylePainter painter, UnityEngine.UIElements.MeshGenerationContextUtils+TextParams textParams, System.Single pixelsPerPoint) (at Library/PackageCache/com.unity.ui@1.0.0-preview.13/Text/TextCoreHandle.cs:116)
UnityEngine.UIElements.UIR.Implementation.UIRStylePainter.DrawText (UnityEngine.UIElements.MeshGenerationContextUtils+TextParams textParams, UnityEngine.UIElements.ITextHandle handle, System.Single pixelsPerPoint) (at Library/PackageCache/com.unity.ui@1.0.0-preview.13/Core/Renderer/UIRStylePainter.cs:359)
UnityEngine.UIElements.MeshGenerationContextUtils.Text (UnityEngine.UIElements.MeshGenerationContext mgc, UnityEngine.UIElements.MeshGenerationContextUtils+TextParams textParams, UnityEngine.UIElements.ITextHandle handle, System.Single pixelsPerPoint) (at Library/PackageCache/com.unity.ui@1.0.0-preview.13/Core/Renderer/UIRMeshGenerationContext.cs:721)
UnityEngine.UIElements.TextElement.OnGenerateVisualContent (UnityEngine.UIElements.MeshGenerationContext mgc) (at Library/PackageCache/com.unity.ui@1.0.0-preview.13/Core/TextElement.cs:176)
UnityEngine.UIElements.VisualElement.InvokeGenerateVisualContent (UnityEngine.UIElements.MeshGenerationContext mgc) (at Library/PackageCache/com.unity.ui@1.0.0-preview.13/Core/VisualElement.cs:1317)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()