Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. File.WriteAllText(Path.Combine(_directoryPath, fileName), _text, System.Text.Encoding.ASCII);
  2.  
  3. #if PLATFORM_ANDROID && !UNITY_EDITOR
  4. TextAsset textAsset = new TextAsset(System.IO.File.ReadAllText(filePathAndName));
  5. #elif UNITY_EDITOR
  6. TextAsset textAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(filePathAndName);
  7. #endif
  8.  
  9. #if PLATFORM_ANDROID && !UNITY_EDITOR
  10. SavedTextsCompleteFilePath = Application.persistentDataPath;
  11.  
  12. // just for debugging and playing in the editor
  13. #elif UNITY_EDITOR
  14. SavedTextsCompleteFilePath = "Assets/Resources";
  15. #endif
  16. // set the base file path, then add the directory if it's not there yet
  17. SavedTextsCompleteFilePath = MakeFolder(SavedTextsCompleteFilePath, "MyGameSaveFolder");
  18. }
  19.  
  20. private string MakeFolder(string path, string savedTextsFolder)
  21. {
  22. string saveDirectory = path + savedTextsFolder;
  23. if (!Directory.Exists(saveDirectory))
  24. {
  25. Directory.CreateDirectory(saveDirectory);
  26. Debug.Log("directory created! at: " + path);
  27. }
  28. return saveDirectory;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement