Guest User

Untitled

a guest
Mar 22nd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. public class FileInOut : MonoBehaviour {
  2.  
  3. string plainText = "";
  4. TextMesh textmesh;
  5.  
  6. // Use this for initialization
  7. void Start () {
  8.  
  9. textmesh = GameObject.Find ("Text").GetComponent<TextMesh> ();
  10. //test if Text changes normally
  11. textmesh.text = "Hallo";
  12.  
  13. //create the text file and put text into it
  14. #if WINDOWS_UWP
  15.  
  16. Task task = new Task(
  17.  
  18. async () =>
  19. {
  20. StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
  21. StorageFile textFileForWrite = await storageFolder.CreateFileAsync("LocalText.txt");
  22. await FileIO.WriteTextAsync(textFileForWrite, "Test Start");
  23. });
  24. task.Start();
  25. task.Wait();
  26.  
  27. #endif
  28. }
  29.  
  30. // Update is called once per frame
  31. void Update () {
  32. //Read the text file and change the text of 3D text to it (not working)
  33. #if WINDOWS_UWP
  34.  
  35. Task task = new Task(
  36.  
  37. async () =>
  38. {
  39. StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
  40. StorageFile textFileforRead = await storageFolder.GetFileAsync("LocalText.txt");
  41. plainText = await FileIO.ReadTextAsync(textFileforRead);
  42. textmesh.text = plainText;
  43.  
  44.  
  45. });
  46. task.Start();
  47. task.Wait();
  48.  
  49. #endif
  50. }
  51. }
Add Comment
Please, Sign In to add comment