1
\$\begingroup\$

So I've created a text asset in Unity of a binary file which i'm attempting to read in as a byte array.

The result I'm getting is a byte array tht is almost half the size it's supposed to be.

The file is a serialized mesh file from here: http://wiki.unity3d.com/index.php?title=MeshSerializer2

What I do then is find the file unity created, move it to the assets folder and drag it into a component as a TextAsset. For smaller files it works but larger ones appear to fail to load completely.

If I load the same file separately from a C# console application using filestream it loads correctly.

\$\endgroup\$
  • 2
    \$\begingroup\$ When you want Unity to load a non-text file as a text asset properly, you need to give it the file extension .bytes. Did you do that? \$\endgroup\$ – Philipp Oct 17 '16 at 10:42
  • \$\begingroup\$ I actually tried that shortly after making this post and it worked, feel free to put that in as an answer andI'll mark it correct. \$\endgroup\$ – meds Oct 17 '16 at 12:59
2
\$\begingroup\$

When you want Unity to load a non-text file as a text asset properly, you need to give it the file extension .bytes. Otherwise it is possible that Unity interprets certain bit sequences as the end of the file and truncates it. It is also required to allow you to access the bytes property of the text asset, which you will likely need for your use-case.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.