GUI: non-static text won't display on Mobile/Web player

Hello, my project uses GUI labels floating in a circular pattern around the player to display the relative directions of points of interest, kind of like a compass/radar display. For now the only element on display is the _name of the object, which is pulled and assigned randomly from a rather large text file.

GUI.Label(new Rect(x,y,Screen.width/5,Screen.height/5), _name);

The labels and attached text are all displaying without a hitch in the editor and the Windows build. The problem is that Web Player and Android will not render the text and over the past 9 hours I’ve tried all (of the very few) workarounds I could find on google without success.

The frustrating thing is that hard coded GUI elements are rendering without any problems:

GUI.Button (new Rect (0,Screen.height - Screen.height/5,Screen.width/5,Screen.height/5), "Dock")

All I’ve learned is that mobile doesn’t support dynamic text, but I have no way of predicting which names will be generated so I can’t set them before runtime.

Does anyone know of a possible solution short of stitching together alphabet textures to form a name based on the string value?

It sounds to me like you need to install a font on the device. If you are using the default font it will work fine in the editor, but will not work on the device.

The whole thing about dynamic fonts is that you cannot change the size of a font on the phone, but you can change the text just fine.

Create a font for each point size you need and then switch between then.

For the benefit of anyone that might be having these problems in the future, I have a working script that should be cross platform, tested on windows, web player, and Android:

void GenNames()
{
	int rand = 0;

	TextAsset textAsset = (TextAsset)Resources.Load("altplanetnames", typeof(TextAsset));
	string ta = textAsset.ToString();
	string[] names = ta.Split('

');

	foreach(Planet p in planets)
	{
		rand = Random.Range(rand, names.GetLength(0));
		p.SetName(names[rand]);
	}
	
}

I experimented with a few input reader types and Regex, none of them worked, TextAsset.ToString() and string.Split() got the job done.