Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Unity: Problem with UI Text not visible in Build only.

A topic by Voidjumper created Aug 02, 2017 Views: 6,477 Replies: 2
Viewing posts 1 to 2

In Unity, I'm trying to display some strings from a string[] in a UI text field. The string[] is populated with strings pulled from a JSON file. I made sure to save the file using the Unicode encoding, and use File.ReadAllText also with the Unicode encoding. I've set my text fields to display Unicode as well as have both vertical and horizontal Overflow. I even set my font's import settings from Dynamic to Unicode.

However I have a problem. I have three text fields, they all have some default, standard text in them. On pressing enter I pull the data from the JSON file. And it updates the text boxes. Pressing up and down will cycle through the strings in the array. Two of the text fields are showing a string from two arrays populated by two differnt JSON files. The third is just showing an array I populated myself by using a for loop and filling it with "No. #" + i.

In the Editor, everything works without a hitch. In the Game View everything works without a hitch. On Build, when I start the game I can see all 3 text fields with their default text. However as soon as I press enter to their text, I can no longer see them and cycling through shows nothing. I can still see my third dummy text box with the "No. #x" strings that I filled in.

This leads my to conclude somehow, probably due to encoding, the Build of the game won't show my text.

If anyone had any solutions I'd be extremely grateful as my game features a fair bit of text...

(2 edits)

It is hard to know, but it kind of sounds to me like it might be the setting in your text components for vertical and horizontal overflow. Try setting those to Overflow instead of wrap and see if you get different results in the build. It could also be the anchor points. Make sure your Canvas Text objects have the anchor points set right at the corners of their bounding boxes. And make sure your canvas is set to scale with screensize.

Hi, thanks.

I did mention I had tried setting the overflow:

> "I've set my text fields to display Unicode as well as have both vertical and horizontal Overflow. "

However I found the source of the problem. It was in the way Unity is packaging JSON files, which get assembled weirdly on build, so much so that a filepath in one's JSON parser can't access them. I moved it into Streaming Assets which are left alone on build, the parser could read the file and the text set itself fine after that.

Thank you for the response.