This is what I currently am doing, what I want to do is have the file be part of the package and read it from the package instead. Later I want to read it from an external source that is streamed to it, but for now, I need it read statically in the package.
using (StreamReader sr = new StreamReader("assets/dungeons/static/basic1/map0.txt"))
{
string line;
while ((line = sr.ReadLine()) != null)
{
buildList.Add(line);
}
}
string pname = System.IO.Path.Combine(Application.dataPath,fileName);
StreamReader sr = new StreamReader(pname, Encoding.UTF8);
string text = sr.ReadToEnd();
sr.Close();
Other than having the text files in a sub folder under the assets folder, I assumed everything from there would be built into my package.
Looking over that linked script area now.
It all works in the editor, its just after the build that it doesn’t find the file.
That’s really not what one wants: people keep all kinds of files and backups and whatnot in the assets folder. If all those went into the game builds, those could get enormous. Instead, Unity tracks which files are used in your scenes, and ignores everything else.
The page I linked in the earlier post explains how you can customize your build process, which includes being able to copy files into the built game.
The page just suggested using the script file, but doesn’t give any example of how to include a folder or a list of files in the package also.
So what would the script look like if I had a folder under my assets folder that I wanted to include with all of its contents?
This way when the player loads and I look for the file based on the System.IO that I posted, will it find it in the package? Unfortunately its not to clear to me how that thing works or is supposed to work.