Enter Play Mode error 'Cannot set the parent of TMP UI SubObject'
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:
- Create TMP Text object on Canvas
- Set some font. I used cyrillic one.
- Add TMP Animator
- Enter Play Mode
- See error
Screenshots
Desktop:
- OS: Windows 11
- UnityVersion: 2022.3.24f1
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?
Have you made sure it works fine without the TMPAnimator component? Also can you give me the full callstack of the error?
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
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
Трафарет ГОСТ 14192- 96 SDF.zip This is my font asset. Style tags: <color=#A3C2A3><link="ANR"><wave>
Couldnt repro the issue, seems to work fine for me
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
I don't enable/disable related objects but change text content from script
Can you send me your project files?
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
Cool, will take a look later today
Oof totally forgot about this sorry. Will take a look next chance I get.
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
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