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