Sprite in Text, Error when Default Sprite Asset of Panel Text Settings have one or more Fallback Sprite Assets

Hello everyone :slight_smile:

I encounter an issue on the unity version 2023.2.11f1.
I reproduce it in the unity version 6000.0.10f1 and 6000.0.22f1

To give you some context :
We have in our current project many Sprites Atlas for different kind and size of icons.
Currently we want to have the possibility to add some sprite of this atlas inside text of our Labels of UIToolkit (via the RichTag system).

I use and follow this documentation to do that :slight_smile:

So currently i have :

My PanelSettings with my TextSettings

My TextSettings with my PlaceHolder Sprite Asset

My PlaceHolder Sprite Asset with 2 Fallback sprite assets

Two labels with this content:

  • < sprite name=“FlagsIcons32IconsBoard_0” >
  • < sprite name=“GlobalIcons32IconBoard_30” >

In Editor play, i can’t see my icons for a repro of 1/5 and have one of the three exceptions throw (see bellow)

In a windows build, i can’t see my icons for a repro of 9/10 and have one of the three exceptions throw (see bellow)

I already know it’s normal i can’t see my icon inside the UIBuilder and i haven’t any problems, if I try to open an UXML with this label (i just have the tag visible as a text, but no exception)

Exceptions list :

  • Most of the time =>
> InvalidCastException: Specified cast is not valid.
> UnityEngine.TextCore.Text.TextGenerator.ParsingPhase
  • OR less often
> NullReferenceException: Object reference not set to an instance of an object
> UnityEngine.TextCore.Text.TextGenerator.ParsingPhase
  • OR rarely
> InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
> System.Collections.Generic.HashSet`1[T].AddIfNotPresent (T value) (at <f938b75b1c74449db620e9bbd958bc0a>:0)
> System.Collections.Generic.HashSet`1[T].Add (T item) (at <f938b75b1c74449db620e9bbd958bc0a>:0)
> UnityEngine.TextCore.Text.SpriteAsset.SearchForSpriteByHashCodeInternal


After some test i have a “workaround”.

If i don’t specify Fallback sprite assets and use only one sprite asset, i don’t have any of this exception and everything is fine … but it’s a bit restrictive …

Have you some advice about this subject ? Have I done everything correctly or does this indeed seem to be a bug ?

Thanks

Hi @gaetan_cordonnier! This sounds like a bug to me. Would you mind reporting the issue ? (See How to Report a bug)

Thanks for bringing this up!

Hello,

Thanks for the answer. I’m gonna ask if i need to reproduce this issue in a specific project or if i can report the bug inside our current project (because i see i need to add some files inside the report)

I update this thread when it’s done

Hello :slight_smile:

It’s reported IN-87077 !

Have a good day.

1 Like

Hello @HugoBD-Unity ,

Can you take a look again to the bug ticket please?

The ticket as been closed quickly and the answer can’t be apply (or maybe i just don’t understand the answer) as i reply on it.

(I try to test it as i said in the ticket IN-87077)

I don’t know th process in that case :confused:

Thk you

Hi @gaetan_cordonnier!

Sorry for the confusion—our discussion wasn’t linked to the ticket, and the ticket itself lacked some context on the issue.

It’s reopened now!