I’ve finished a game which relies on reading level data from a raw text file with a StreamReader (C#), and while this works just fine in the debugger, it simply doesn’t when I port it for Mac OSX.
This got me wondering some best practices are for ensuring compatibility and reliability when doing file I/O in C# in general.
To avoid all the platform differences, where possible I always use Unity’s asset system.
Add files to a Resource folder and have unity include them with the standard game assets. For example you could save your levels like (note, the extension is important - use .txt for text data, and .bytes for binary data):
Thanks Larku! I’ve seen some others talk about the same sort of approach… is ‘Resources’ just an arbitrary folder name, or is there something more to it than that?
Not arbitrary, essentially files included in any Resources folder under your Assets folder (anywhere under the Assets folder) are included with your assets at build time. So: