Search Maya Zest



Sunday, October 24, 2021

Playmaker Load external files from StreamingAssets folder can't load file

I hit enough issues trying to load external files from the streaming assets folder I thought I would make a little tip about this.

Firstly, I discover that using the "Load From File" action pointing to the file path you are trying to use creates an interesting issue problem.
 


For example here is the path to a text file

"StreamingAssets/Folder1/Text.txt" 

IMPORTANT:

This path WORKS in the unity editor, but NOT in a standalone build. HERE IS THE KICKER though IT WILL work if you do a BUILD AND RUN. Which APPEARS to be your standalone build but it's NOT when it comes to that file path. This is highly confusing and took quite a bit to realize. 

Here is the solution:

Instead of creating your file path use the action in the eco system. "Get streaming assets data path" as of this writing you need to modify this action though. ( I might try to ping them and see if they will update it) It currently points to the persistent data path. You need to just tweak the one line in the action script to change it to get to the streaming assets folder instead.


Change this line 30

            streamingAssetsDataPath.Value = Application.persistentDataPath;


Change to:

            streamingAssetsDataPath.Value = Application.streamingAssetsPath;


Save and recompile, now do a build but NOT a build and run. Just Run your EXE to test. It should load the file now.

Now for the file to load when using the EDITOR you can use "Runtime Platform event" that will detect if it's a standalone or editorun and if it's the editor you need to just us a path prefix that is this. Then append your folder and file name to that.
 

Assets/StreamingAssets/

Now you should be able to load files from the streaming resources folder AND the streaming resources folder in the editor at the same time!