A Nerd's False Positive.

Fix: Unity3d InputText foreground color white in Android

Last week, I was creating an Android app using Unity. However, when I deployed the app to device, I noticed that foreground color of input control is in white color but renders as expected in Unity editor and in other platform targets.


Add the below style in AndroidManifest.xml file and the issue will be resolved.



Error: Document element did not appear. Line 1, position 1 in Unity3d

I was trying to serialize and deserialize a class instance that saves some scene details in Unity3d. Though the instance was serializes successfully deserialization was failing with error – “Error: Document element did not appear.  Line 1, position 1.” every time. This was driving me nuts because the same serialization/deserialization code works fine in a console c# application.

The issue was related to BOM that’s included at the very beginning of the text file to know it’s encoding. This struck me because whenever I try to open c# script file from Unity, my Visual Studio always prompted to correct the encoding and line spacing of the file.

The error is annoying, but fix is relatively very simple. Do specify UTF8 encoding when you deserialize the file which will do the trick.

using (StreamReader reader = new StreamReader("filename", new UTF8Encoding(false)))

Hope this helps.