FBFile.cs 811 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.IO;
  3. using UnityEngine;
  4. namespace Tools
  5. {
  6. public class FBFile
  7. {
  8. public static bool SaveToFile(string path, string name, string str)
  9. {
  10. UnityEngine.Debug.LogError(path + name + " 不能在非编辑器下保存");
  11. return false;
  12. }
  13. public static string LoadFromFile(string path, string name)
  14. {
  15. string result = string.Empty;
  16. TextAsset textAsset = Resources.Load<TextAsset>(Path.Combine(path, name));
  17. if (textAsset != null)
  18. {
  19. result = textAsset.text;
  20. }
  21. else
  22. {
  23. Log.Error(Path.Combine(path, name) + " 文件不存在");
  24. }
  25. return result;
  26. }
  27. public static bool IsFileExist(string path, string name)
  28. {
  29. UnityEngine.Object x = Resources.Load(Path.Combine(path, name));
  30. return x != null;
  31. }
  32. }
  33. }