Z
Z
Zefirot2021-12-08 14:50:43
C++ / C#
Zefirot, 2021-12-08 14:50:43

Why is the modified file not immediately read?

I take a room in the editor and on the basis of this I generate a text file
1st option

string tx ="Some Info....";
if(File.Exists(PathFile)){
  using(FileStream fs = new FileStream(PathFile, FileMode.Truncate)){
    using(StreamWriter wr = new StreamWriter(fs)){ wr.Write(tx); }
    }
  }

2nd option
string tx ="Some Info....";
if(File.Exists(PathFile)){ 
  StreamWriter sw = new StreamWriter(PathFile);
  sw.WriteLine(tx);
  sw.Close();
  }

I read
string tx = Resources.Load<TextAsset>(PathFile).ToString();

Then I immediately go to check in practice what and how it has changed, I launch it, that is, this file is read that has just been overwritten and ... there are no changes ... what is it? I go to read what is in this file, and everything is fine there, I launch it again and see that the changes have already taken effect ...
After trying several times, I realized the following, no matter how many times I save it with a script until I physically open it and look at it myself file changes will not be made, some kind of nonsense ...

What could be such a problem? That is, on the one hand, everything is recorded, on the other hand, the version is read before the changes until I open the file myself so I won’t look ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2021-12-08
@Zefirot

You may need to call a resource update. Especially if all this is done without changing the unit mode (editor / hacked game).
https://answers.unity.com/questions/472352/force-u...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question