Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-ASCII characters are not displayed properly with TextMeshProUGUI and SoftMask. #216

Closed
wiseyestudio00 opened this issue Dec 15, 2024 · 15 comments
Assignees
Labels
bug Something isn't working released

Comments

@wiseyestudio00
Copy link

wiseyestudio00 commented Dec 15, 2024

To Reproduce
Steps to reproduce the behavior:

  1. Create a TextMeshPro FontAsset with English font, and attach non-English font to its fallback list (I am using Noto Serif)
  2. Create a Canvas with RenderMode set to Camera, and attach a Camera to it.
  3. Create TextMeshProUGUI component under a SoftMask parent.
  4. Non-English texts are not displayed correctly (see screenshots below).

Expected behavior
The texts should be displayed properly.

Screenshots
Screenshot_0
^ English (Displaying properly)
Screenshot_1
^ Traditional Chinese (Error)
Screenshot_2
^ Japanese (Error)

Screenshot_3
^ If I remove the SoftMask in Viewport, the error goes away.

Screenshot_4
^ Setting Masking Mode to Normal works correctly, as well as Anti-Aliasing.

圖片
^ How the font is set up. The font itself is a static font with ASCII characters, with 3 fallback Japanese font (first 2 static, the last is dynamic fallback).

Screenshot_5
^ Overlay causes error too; If I set the RenderCamera to overlay, the problematic texts disappear.

Environment (please complete the following information):

  • Version 3.0.1
  • Platform: Windows Editor
  • Unity version: 6000.0.29f1
  • Build options: [e.g. IL2CPP, .Net 4.x, LWRP]
  • Unity 6 Text Mesh Pro Support is imported.

Additional context
I upgraded from 1.0.2, where the same error also existed.

UPDATE:
If I manually toggle on and off the "Ignore Children" option in Soft Maskable on the TextMeshProUGUI component, the texts starts rendering properly.

圖片
^ Before toggle On
圖片
^ Toggle On
圖片
^ Toggle Off (texts start displaying properly.)

@wiseyestudio00 wiseyestudio00 added the bug Something isn't working label Dec 15, 2024
@mob-sakai
Copy link
Owner

Thank you for your reporting!
Could you please attach a minimal project (included Assets, Packages and ProjectSettings directories) that reproduces the issue?
Of course, you don't need to include any secret assets from your project. Feel free to use free assets instead.

repos

@mob-sakai
Copy link
Owner

@wiseyestudio00
Copy link
Author

Thank you for your reporting! Could you please attach a minimal project (included Assets, Packages and ProjectSettings directories) that reproduces the issue? Of course, you don't need to include any secret assets from your project. Feel free to use free assets instead.

repos

I am sorry, but this project has grown really large and it will be pretty complex & will take a long while to create a minimal project. Is it possible that I just privately share a fork of the project with you instead?

@wiseyestudio00
Copy link
Author

As an alternative: Consider using RectMask2D or Anti-Aliasing mask mode.

https://github.com/mob-sakai/SoftMaskForUGUI?tab=readme-ov-file#rectmask2d-vs-softmask

https://github.com/mob-sakai/SoftMaskForUGUI?tab=readme-ov-file#comparison-of-masking-mode

I would love to, but I also want to use the SoftMask effect, especially in other parts of the project......I am not too tight on the time constraint, so I can resolve this issue with you + I think this will really benefit SoftMask's usability with other languages! It's so close to being the perfect solution for Soft-Masking in Unity!

@mob-sakai
Copy link
Owner

Is it possible that I just privately share a fork of the project with you instead?

Yes, that's no problem.

@wiseyestudio00
Copy link
Author

wiseyestudio00 commented Dec 15, 2024

Hi! Sorry it took a while. I just share the fork with you. To start, please start from with CompleteRestartScene, which should lead you automatically to TitleScreen, where you can access PlayerSetting Menu. Scroll to the bottom to change language to see the error!

  • Sorry I may have to go to sleep now. I will reply if there is any progress tomorrow! Thank you so much!

@mob-sakai
Copy link
Owner

Okay, I cloned that repository. 👍

@mob-sakai
Copy link
Owner

mob-sakai commented Dec 16, 2024

Playing a CompleteRestartScene scene causes an error.

NullReferenceException: Object reference not set to an instance of an object
WiseyeStudio.Lily.Preload.PreloadMenuManager.StartAsync (System.Threading.CancellationToken cancellationToken) (at Assets/Scripts/WiseyeStudio/Lily/Preload/PreloadMenuManager.cs:57)
Cysharp.Threading.Tasks.UniTask+ExceptionResultSource.GetResult (System.Int16 token) (at ./Library/PackageCache/com.cysharp.unitask/Runtime/UniTask.Factory.cs:326)
Cysharp.Threading.Tasks.UniTask+Awaiter.GetResult () (at ./Library/PackageCache/com.cysharp.unitask/Runtime/UniTask.cs:316)
Cysharp.Threading.Tasks.UniTask+WhenAllPromise.TryInvokeContinuation (Cysharp.Threading.Tasks.UniTask+WhenAllPromise self, Cysharp.Threading.Tasks.UniTask+Awaiter& awaiter) (at ./Library/PackageCache/com.cysharp.unitask/Runtime/UniTask.WhenAll.cs:200)
--- End of stack trace from previous location where exception was thrown ---
Cysharp.Threading.Tasks.UniTaskCompletionSourceCore`1[TResult].GetResult (System.Int16 token) (at ./Library/PackageCache/com.cysharp.unitask/Runtime/UniTaskCompletionSource.cs:244)
Cysharp.Threading.Tasks.UniTask+WhenAllPromise.GetResult (System.Int16 token) (at ./Library/PackageCache/com.cysharp.unitask/Runtime/UniTask.WhenAll.cs:218)
Cysharp.Threading.Tasks.UniTask+Awaiter.GetResult () (at ./Library/PackageCache/com.cysharp.unitask/Runtime/UniTask.cs:316)
WiseyeStudio.Lily.Preload.PreloadSceneManager.Start () (at Assets/Scripts/WiseyeStudio/Lily/Preload/PreloadSceneManager.cs:63)
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) (at <a6d715f5ce8c4754a140b50ff638878a>:0)
UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs:155)
UnityEngine.UnitySynchronizationContext.Exec () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs:83)
UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs:109)

Edit: PreloadMenuManager scene > PreloadMenuManager.TutorialStoryBlock is null.

Notification_Center

Edit: Skipped tutorial to show screen.

-           if (playerData.HasStatus(LilyFantasiaPlayerStatusKey.Completed_Tutorial_Song))
            {
                await LoadingScreenSpawner.LoadNextSceneAsync(
                    new LoadingScreenArgument(
                        SceneNames.TitleScreenScene,
                        durationInSecond: 1f,
                        animationMode: LoadingScreenAnimationMode.WhiteFade)
                    );
            }
-           else
-           {
-               var blockData = TutorialStoryBlock.CreateData();
-               await new StoryBookEnterNextSceneUtility().PlayFullStoryWithSongAsync(
-                   SceneNames.PreloadScene,
-                   SceneNames.TitleScreenScene,
-                   blockData,
-                   0,
-                   cancellationToken
-               );
-           }

@mob-sakai
Copy link
Owner

The issue is reproduced on my environment.

image

@wiseyestudio00
Copy link
Author

I am sorry for the error! I was trying to create a fork in a hurry, so the mistake must have slipped through. Glad to see the error being reproducible though!

@mob-sakai
Copy link
Owner

mob-sakai commented Dec 21, 2024

As a workaround: by deactivating the relevant objects, they were displayed correctly.

image

Or, apply this patch: UtilityHubMenuManager.patch.zip

@mob-sakai
Copy link
Owner

mob-sakai commented Dec 21, 2024

By adding a delay before hiding the submenu, it was displayed correctly.

await UniTask.Delay(500, cancellationToken: CancellationToken.None);
await HideAllSubMenuAsync(0f, CancellationToken.None);

Considering the previous patch (calling gameObject.SetActive(true) after hiding the submenu), it seems that TextMeshProUGUI is processing "something" asynchronously when activated for the first time.

If we can find an accessible event that notifies when it completes, everything will be resolved!

@mob-sakai
Copy link
Owner

image

This may be due to the SoftMaskable component being above the SubMeshUI component.

@mob-sakai
Copy link
Owner

image

PERFECT!
I will release it soon. Good night.

github-actions bot pushed a commit that referenced this issue Dec 22, 2024
# [3.1.0](3.0.1...3.1.0) (2024-12-22)

### Bug Fixes

* soft masking for SubMesheUI (TextMeshProUGUI) may not display correctly ([d417c06](d417c06)), closes [#216](#216)

### Features

* maskingShape with TextMeshPro ([858655f](858655f)), closes [#217](#217)
@mob-sakai
Copy link
Owner

🎉 This issue has been resolved in version 3.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

No branches or pull requests

2 participants