源战役客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

49 linhas
1.6 KiB

  1. #if UNITY_EDITOR
  2. using UnityEditor;
  3. //路径保存器,记录上次打开的路径,不同项目的不同用处路径都分开保存
  4. namespace U3DExtends
  5. {
  6. public enum PathType {
  7. //OpenLayout,//打开布局时默认打开的文件夹路径//和Save用同个会方便点
  8. SaveLayout,//保存布局时默认打开的文件夹路径
  9. OpenDecorate,//选择参考图时默认打开的文件夹路径
  10. PrefabTool,//Prefab界面用的
  11. }
  12. public class PathSaver {
  13. private volatile static PathSaver _instance = null;
  14. private static readonly object lockHelper = new object();
  15. private PathSaver() { }
  16. public static PathSaver GetInstance()
  17. {
  18. if(_instance == null)
  19. {
  20. lock(lockHelper)
  21. {
  22. if(_instance == null)
  23. _instance = new PathSaver();
  24. }
  25. }
  26. return _instance;
  27. }
  28. public string GeDefaultPath(PathType type)
  29. {
  30. return "";
  31. }
  32. public string GetLastPath(PathType type)
  33. {
  34. return EditorPrefs.GetString("PathSaver_" + U3DExtends.Configure.ProjectUUID + "_" + type.ToString(), GeDefaultPath(type));
  35. }
  36. public void SetLastPath(PathType type, string path)
  37. {
  38. if (path == "")
  39. return;
  40. path = System.IO.Path.GetDirectoryName(path);
  41. EditorPrefs.SetString("PathSaver_" + U3DExtends.Configure.ProjectUUID + "_" + type.ToString(), path);
  42. }
  43. }
  44. }
  45. #endif