From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XEditor/XSkillEditor/XEditorPath.cs | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Client/Assets/Scripts/XEditor/XSkillEditor/XEditorPath.cs (limited to 'Client/Assets/Scripts/XEditor/XSkillEditor/XEditorPath.cs') diff --git a/Client/Assets/Scripts/XEditor/XSkillEditor/XEditorPath.cs b/Client/Assets/Scripts/XEditor/XSkillEditor/XEditorPath.cs new file mode 100644 index 00000000..6e85d8d6 --- /dev/null +++ b/Client/Assets/Scripts/XEditor/XSkillEditor/XEditorPath.cs @@ -0,0 +1,85 @@ +#if UNITY_EDITOR +using System; +using UnityEditor; + +namespace XEditor +{ + public class XEditorPath + { + public static readonly string Sce = "Assets/XScene/"; + public static readonly string Cts = "Assets/Resources/CutScene/"; + public static readonly string Skp = "Assets/Resources/SkillPackage/"; + public static readonly string Crv = "Assets/Editor/EditorResources/Curve/"; + public static readonly string Cfg = "Assets/Editor/EditorResources/SkillPackage/"; + public static readonly string Scb = "Assets/Resources/Table/SceneBlock/"; + public static readonly string Lev = "Assets/Resources/Table/Level/"; + + private static readonly string _root = "Assets/Resources"; + private static readonly string _editor_root = "Assets/Editor"; + private static readonly string _editor_res_root = "Assets/Editor/EditorResources"; + + public static string GetCfgFromSkp(string skp, string suffix = ".config") + { + skp = skp.Replace("/Resources/", "/Editor/EditorResources/"); + int m = skp.LastIndexOf('.'); + + return skp.Substring(0, m) + suffix; + } + + private static void RootPath() + { + if (!System.IO.Directory.Exists(_root)) + { + AssetDatabase.CreateFolder("Assets", "Resources"); + } + } + + private static void EditorRootPath() + { + if (!System.IO.Directory.Exists(_editor_root)) + { + AssetDatabase.CreateFolder("Assets", "Editor"); + } + + if (!System.IO.Directory.Exists(_editor_res_root)) + { + AssetDatabase.CreateFolder("Assets/Editor", "EditorResources"); + } + } + + public static string BuildPath(string dictionary, string root) + { + string[] splits = dictionary.Split('/'); + string _base = root; + + foreach (string s in splits) + { + string path = _base + "/" + s + "/"; + + if (!System.IO.Directory.Exists(path)) + { + AssetDatabase.CreateFolder(_base, s); + } + + _base = path.Substring(0, path.Length - 1); + } + + return _base + "/"; + } + + public static string GetEditorBasedPath(string dictionary) + { + EditorRootPath(); + + return BuildPath(dictionary, _editor_res_root); + } + + public static string GetPath(string dictionary) + { + RootPath(); + + return BuildPath(dictionary, _root); + } + } +} +#endif \ No newline at end of file -- cgit v1.1-26-g67d0