I have .csv
file in asset folder.
While I am running project in Unity everything is ok. But once I start compiling a build under Windows application cannot read that file.
How to access it?
I have .csv
file in asset folder.
While I am running project in Unity everything is ok. But once I start compiling a build under Windows application cannot read that file.
How to access it?
I don’t think you can access the assets from a build.
What you can do is use a TextAsset
. In the script you want to use the .csv
from, add a public TextAsset csvFile;
variable. Then you can drag your file in the variable in the inspector and access the text using csvFile.text
And then if you want to save it as a file in the build, to modify the file or allow users to access it for example, you can write the text to a new file in Application.persistentDataPath
.
If you change files in the asset folder during a build, things can get messed up, so you can’t edit the unity project during a build. I can’t see why you would need to look at it in the first place, however. Just wait until it finishes.
You can try to close the .csv
file first, or make sure your .csv
has been saved before compiling.
Try using Application.persistentDataPath
instead of Application.dataPath
Another option that could help is using Resources
to save the file, more info here:
Unity - Scripting API: Resources