I have a text file in the resource folder that holds some values that variables in my game use (ex: health, mana). I want the user to be able to write to that file from one scene, and load them in another. Its kind of working. Except when I press save the file gets changed but i need to quit unity or stop the play mode in order for these changes to commit. So if i change mana for example from 100 to 200, id have to exit and when i re-enter play mode its 200. I need that change to happen so that the next scene would read these variables. Also if im in play mode, and i change a value, when i open the text file in the editor it asks me to reload, and when i do the changes actually commit and im still in play mode, but i need that to happen in game alone.
Would appreciate some help.
if im in play mode, and i change a value, when i open the text file in the editor it asks me to reload, and when i do the changes actually commit and im still in play mode
So I assume you are closing the file writer ok if the text file is being updated. You can refresh the project window view with :
UnityEditor.AssetDatabase.Refresh();
You can also just refresh the text file with Unity - Scripting API: AssetDatabase.ImportAsset
This is just for the editor (as you want to see the text file change in the editor), you may have to encapsulate the command in a platform dependant directive to avoid build complications, eg:
#if UNITY_EDITOR
UnityEditor.AssetDatabase.Refresh();
#endif