Crashes when assigning a Non-latin serializable character in inspector. What is the workaround?

Working code for roman:

[SerializeField] char _letter = 'a';

Issue with any other non-Latin character

[SerializeField] char _letter = 'অ';

I remember a similar issue in the past with Unity. I think it had something to do with with characters that use more bits when interpreted in UTF8. The character in your example uses just 16 bits in UTF16, but 24 in UTF8.


  • I’m almost sure this won’t happen if you store the character in a string. You’d have to validate the string to make sure it only has one character; on the plus side, this way you could store characters that don’t fit in a char (i.e. characters that use more than 16 bits in UTF16);

  • You could describe your case more; you could put steps to reproduce the crash, describe how these fields are used, and say more about your project and your tools. This can make it easier for people to know whether they know something about your problem; for example, sometimes these errors only happen with some plugins or in some OS. It also helps to get suggestions for workarounds that actually fit your case.

That’s strange. Maybe it depends on Unity version? I use 2019.4.28f1 Personal. Both of those two variables display the same letter in the inspector without any crash.

	[SerializeField] char _letter1 = 'অ';
	[SerializeField] char _letter2 = '\u0985';