0

I made a simple tool in Unity that saves user data into binary files - later on I use those binary files to initialize scenes based on different conditions.

I am placing those binary files in the Resources folder, and that works well in the editor, however when I make a build for Windows, the app cannot find any file in the path. There fore I need to use Resources.Load, which retrieves a type Object, but in order to open and read the contents of such file I need to use the BinaryReader which takes a Stream or FileStream.

I'd appreciate any help on the matter. If what I am trying to do it is not possible, I'd appreciate any indications on how to load bespoke binary files in run time (without using serialization or xml).

Many thanks in advance!!

Programmer
  • 121,791
  • 22
  • 236
  • 328
Cris
  • 197
  • 1
  • 4
  • 16
  • Rename the binary file extension to ".bytes" in the Resources folder. You can use `TextAsset` to load it with `Resources.Load` and can be accessed with `TextAsset.bytes`. See the *Text files:* section from the duplicate. Instead of using `txtAsset.text`, use `TextAsset.bytes`. – Programmer May 10 '18 at 13:34
  • Many thanks for your help Programmer. Actually once I got the array of bytes following your post I managed to use the BinaryReader to read its content using MemoryStream. It works in both editor mode and build. Thanks a lot again for pointing me in the right direction – Cris May 11 '18 at 07:34

0 Answers0