TMPEffects icon indicating copy to clipboard operation
TMPEffects copied to clipboard

Enter Play Mode error 'Cannot set the parent of TMP UI SubObject'

Open lolomap opened this issue 10 months ago • 14 comments

When I enter play mode, I have error: Cannot set the parent of the GameObject 'TMP UI SubObject [(HERE IS NAME OF MY FONT) + LiberationSans SDF Atlas]' while activating or deactivating the parent GameObject 'HERE IS NAME OF MY TMP_TEXT GAMEOBJECT'. It happens even I disable 'Animate On Start'

To Reproduce Steps to reproduce the behavior:

  1. Create TMP Text object on Canvas
  2. Set some font. I used cyrillic one.
  3. Add TMP Animator
  4. Enter Play Mode
  5. See error

Screenshots

Image

Image

Desktop:

  • OS: Windows 11
  • UnityVersion: 2022.3.24f1

lolomap avatar Mar 02 '25 21:03 lolomap

I realised that my font doesn't have "<>" characters, so it generates submesh object automatically and it cannot be handled with TMPEffects. Anyway, I think such behaviour should be handled, right?

lolomap avatar Mar 02 '25 21:03 lolomap

Have you made sure it works fine without the TMPAnimator component? Also can you give me the full callstack of the error?

Luca3317 avatar Mar 03 '25 14:03 Luca3317

It works fine for simple TMPText without TMPAnimator. I migrated to Unity 6 to check if it has same problem and the error changed a little bit:

Cannot set the parent of the GameObject 'New Game Object' while activating or deactivating the parent GameObject 'EventDescription'. 0x00007ffd41889dbd (Unity) StackWalker::ShowCallstack 0x00007ffd41899d79 (Unity) PlatformStacktrace::GetStacktrace 0x00007ffd42b08bbe (Unity) Stacktrace::GetStacktrace 0x00007ffd430b18bf (Unity) DebugStringToFile 0x00007ffd415bf1b5 (Unity) Transform::SetParent 0x00007ffd415cd98e (Unity) SetParent 0x00007ffd409f8000 (Unity) Transform_CUSTOM_SetParent 0x000001aa125a37d6 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Transform:SetParent_Injected (intptr,intptr,bool) 0x000001aa125a366b (Mono JIT Code) UnityEngine.Transform:SetParent (UnityEngine.Transform,bool) 0x000001aa1260c5a3 (Mono JIT Code) TMPro.TMP_SubMeshUI:AddSubTextObject (TMPro.TextMeshProUGUI,TMPro.MaterialReference) (at ./Library/PackageCache/com.unity.ugui@03407c6d8751/Runtime/TMP/TMP_SubMeshUI.cs:218) 0x000001a9baffd6b3 (Mono JIT Code) TMPro.TextMeshProUGUI:SetArraySizes (TMPro.TMP_Text/TextProcessingElement[]) (at ./Library/PackageCache/com.unity.ugui@03407c6d8751/Runtime/TMP/TextMeshProUGUI.cs:2226) 0x000001a9bafe52b1 (Mono JIT Code) TMPro.TMP_Text:ParseInputText () (at ./Library/PackageCache/com.unity.ugui@03407c6d8751/Runtime/TMP/TMP_Text.cs:2017) 0x000001a9bafe4bdb (Mono JIT Code) TMPro.TextMeshProUGUI:OnPreRenderCanvas () (at ./Library/PackageCache/com.unity.ugui@03407c6d8751/Runtime/TMP/TextMeshProUGUI.cs:2471) 0x000001a9bafe462b (Mono JIT Code) TMPro.TextMeshProUGUI:ForceMeshUpdate (bool,bool) (at ./Library/PackageCache/com.unity.ugui@03407c6d8751/Runtime/TMP/TextMeshProUGUI.cs:563) 0x000001aa0f1f8c1f (Mono JIT Code) TMPEffects.Components.TMPAnimator:UnsubscribeFromMediator () (at ./Library/PackageCache/com.luca3317.tmpeffects@d654665d03ac/Runtime/Components/TMPAnimator/TMPAnimator.cs:632) 0x000001aa0f1f844b (Mono JIT Code) TMPEffects.Components.TMPAnimator:OnDisable () (at ./Library/PackageCache/com.luca3317.tmpeffects@d654665d03ac/Runtime/Components/TMPAnimator/TMPAnimator.cs:594) 0x000001a83615fda8 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr) 0x00007ffd3cb868de (mono-2.0-bdwgc) mono_jit_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/mini/mini-runtime.c:3445) 0x00007ffd3cac8404 (mono-2.0-bdwgc) do_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3068) 0x00007ffd3cac84f0 (mono-2.0-bdwgc) mono_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3115) 0x00007ffd417ae0c4 (Unity) scripting_method_invoke 0x00007ffd41785e43 (Unity) ScriptingInvocation::Invoke 0x00007ffd41785f2e (Unity) ScriptingInvocation::InvokeChecked 0x00007ffd41830276 (Unity) SerializableManagedRef::CallMethod 0x00007ffd4177a4f4 (Unity) MonoBehaviour::RemoveFromManager 0x00007ffd410542d2 (Unity) GameObject::ActivateAwakeRecursivelyInternal 0x00007ffd41054110 (Unity) GameObject::ActivateAwakeRecursivelyInternal 0x00007ffd41054110 (Unity) GameObject::ActivateAwakeRecursivelyInternal 0x00007ffd41054110 (Unity) GameObject::ActivateAwakeRecursivelyInternal 0x00007ffd41054110 (Unity) GameObject::ActivateAwakeRecursivelyInternal 0x00007ffd41054110 (Unity) GameObject::ActivateAwakeRecursivelyInternal 0x00007ffd41054110 (Unity) GameObject::ActivateAwakeRecursivelyInternal 0x00007ffd41054110 (Unity) GameObject::ActivateAwakeRecursivelyInternal 0x00007ffd41054110 (Unity) GameObject::ActivateAwakeRecursivelyInternal 0x00007ffd41053d23 (Unity) GameObject::ActivateAwakeRecursively 0x00007ffd41056ff9 (Unity) GameObject::Deactivate 0x00007ffd413e4366 (Unity) DestroyObjectHighLevel_Internal 0x00007ffd413e49dc (Unity) DestroyWorldObjects 0x00007ffd4297ba9f (Unity) EditorSceneManager::RestoreSceneBackups 0x00007ffd42519916 (Unity) PlayerLoopController::EnterPlayMode 0x00007ffd4251b65f (Unity) PlayerLoopController::SetIsPlaying 0x00007ffd42515a35 (Unity) Application::TickTimer 0x00007ffd42b0d8ba (Unity) MainMessageLoop 0x00007ffd42b13564 (Unity) UnityMain 0x00007ff71a632fba (Unity) __scrt_common_main_seh 0x00007ffdbdd3e8d7 (KERNEL32) BaseThreadInitThunk 0x00007ffdbf01bf2c (ntdll) RtlUserThreadStart

lolomap avatar Mar 04 '25 09:03 lolomap

Hmmm I see. IIRC I didnt have this problem with sprite animations which also create submeshes. Can you share your project files? If you dont want to do that, just the font asset and the contents of "<style=ANR>" should be enough

Luca3317 avatar Mar 04 '25 12:03 Luca3317

Трафарет ГОСТ 14192- 96 SDF.zip This is my font asset. Style tags: <color=#A3C2A3><link="ANR"><wave>

lolomap avatar Mar 05 '25 11:03 lolomap

Couldnt repro the issue, seems to work fine for me

Image

Tested in 6 and 2022.3.20 which is the closest version to yours ive had installed. Are you enabling/disabling some related gameobjects from another script?

Also make sure that maybe the font asset isnt just broken. Ive had to create a new one from the .ttf because the asset itself had missing references

Luca3317 avatar Mar 08 '25 17:03 Luca3317

I don't enable/disable related objects but change text content from script

lolomap avatar Mar 10 '25 13:03 lolomap

Can you send me your project files?

Luca3317 avatar Mar 10 '25 13:03 Luca3317

This is my project files: https://drive.google.com/file/d/1jLyuIOjozHmnZ0FkG8-Uqn6vvURKXQUH/view?usp=sharing I tried to recreate asset from .ttf and set new one but I still have this error

lolomap avatar Mar 10 '25 13:03 lolomap

Cool, will take a look later today

Luca3317 avatar Mar 10 '25 13:03 Luca3317

Oof totally forgot about this sorry. Will take a look next chance I get.

Luca3317 avatar Mar 28 '25 12:03 Luca3317

Hey so Id probably have some time over the weekend to check this out. I just took a quick look at the project and two things:

  • Is there some specific scene I should take a look at? It opens on an empty untitled one
  • The font you sent is not present in the project.

It would be best if you set up the scene in the way that causes the issue for you, so I can quickly repro and get to fixing the issue

Luca3317 avatar Apr 04 '25 12:04 Luca3317

There should be "Game" scene in a Assets/Scenes folder and the font should be the only one in Assets/Fonts. I renamed it to GOSTFont to avoid non-english characters. It is used on a scene in visible EventDescription object (Canvas/GamePanel/BottomPanel/EventInfo/DesctiprionScroll/Viewport/EventDescription/Content/EventDescription). Try to run and stop scene several times to get the error

lolomap avatar Apr 11 '25 07:04 lolomap