In C#, there are Unicode escape characters but when I pass them to a button, for example, the result is blank. How is this done?
I figured it out! Note the single quotes are required…
char upArrow = '\u25B2';
GUILayout.Button(upArrow.ToString());
It seems to render the Unicode character slightly off to the right though.
Here is a nice listing of available characters: Unicode 15.0 Character Code Charts
If you want to use the inspector to set unicode characters (for example if you wanted to use font-awesome and actually see the icons when the game isn’t running), you follow these steps:
- Go to this website and search for the character code you want.
- Copy and paste the character from the webpage into the unity inspector.
These can also be used in the console, but as @luislodosm points out characters above \uFFFF are not supported:
Debug.Log ( "\u2665".ToString () + " Text after symbol");