New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Platform.ReadFileBytes(filename) and Assets dir #902
Comments
This is actually the expected behavior! The "Assets folder path" is a trick used to help prevent needing different file names on different platforms, which is why file names behave fine for Assets. But for a function as generic as The main thing here is that on Android, It's definitely confusing, and I do believe Platform.ReadFileBytes is due for some revision. I just haven't decided exactly how to revise this in a way that isn't also confusing in other contexts! Maybe I'm overthinking it and the solution is not all that complicated 😅 I dunno! I'll try and take a look at this soon. |
Right, I figured something like this 😄
Perhaps having a renamed/dedicated Apart from that could be a call to read a regular file, where filename is some form of platform-native path. That at least still provides an abstraction for file I/O over the underlying platform, which can be a nice thing. |
It looks like I have actually put some thought into this one previously, #771 😅 |
This is done in #960, will try and add this to a 0.3.10 soon |
Description
The docs for the
filename
argument ofPlatform.ReadFileBytes(string filename)
say "Path to the file. Not affected by Assets folder path".I'm not sure what the latter part of that sentence implies, but apparently I need to use different paths to the same file, depending on the platform (and so needs a conditional in the code):
ReadFileBytes("myfile.bin")
ReadFileBytes("Assets/myfile.bin")
Is this the expected behaviour, or should it be possible to have the same path in all cases?
Platform / Environment
0.3.9
The text was updated successfully, but these errors were encountered: