Answer the question
In order to leave comments, you need to log in
How to read a previously saved file on build?
The "prefabricated" prefabs weighed a little too much for me and therefore I went for this option - I make this prefab from several prefabs, then I create a file in the editor and save it in a certain folder, this is a text file and it indicates where which prefabs should be located (coordinates , sizes, etc.), prefab 0.5mb-2mb, but txt with info 3kb, so there is a difference.
What is the problem - during the test everything works and reads, but after compiling and installing on the phone, as I understand it, the file does not read ...
It is stored in my editor
\Assets\Resources\Levels\1\Level-1.txt
\Assets\Resources\Levels\1\Level-2.txt
string LevelDataPath = "Assets/Resources/Levels/1/Level-1.txt";
if(File.Exists(LevelDataPath)){
levelData = File.ReadAllText(LevelDataPath);
}
Answer the question
In order to leave comments, you need to log in
Ohh. This is not the first time you have been suffering from this garbage, but you still can’t suffer in any way ... Is the savings really worth these efforts? Is the rest of the game 100% ready?
Answering your question. You have two mistakes. First. For text "configs" you need to use either StreamingAssets (a special folder that is assembled a little differently), or load it as a text resource (I'm not sure about the second one - I haven't used it for a very long time).
The second - I suspect that you are testing on android ... So, reading from StreamingAssets (or from another point in the compiled application) is done not through File, but through UnityWebRequest
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question