public void OnDestroy() { CustomDataUtil.SetKV("ExcelPath", excelPath); CustomDataUtil.SetKV("ExcelDir", excelDir); string saveStr = ""; for (int i = 0; i < assetList.Count; i++) { if (assetList[i] != null) { string assetPath = AssetDatabase.GetAssetPath(assetList[i].GetInstanceID()); int startIndex = assetPath.IndexOf("Resources/") + 10; int endIndex = assetPath.LastIndexOf('.'); saveStr += assetPath.Substring(startIndex, endIndex - startIndex); if (i < assetList.Count - 1) { saveStr += "@"; } } } CustomDataUtil.SetKV("AutoExcelPaths", saveStr); Debug.Log(saveStr); CustomDataUtil.SaveData(); }
public static void ShowWindow() { //创建窗口 ToolsCenter window = (ToolsCenter)EditorWindow.GetWindow(typeof(ToolsCenter), true, "ToolsCenter"); window.Show(); string path = CustomDataUtil.GetVal("ExcelPath"); if (path != null) { window.excelPath = path; } string dir = CustomDataUtil.GetVal("ExcelDir"); if (dir != null) { window.excelDir = dir; } string paths = CustomDataUtil.GetVal("AutoExcelPaths"); window.assetList = new List <ScriptableObject>(); if (paths != null && paths.Length > 0) { string[] pathArray = paths.Split('@'); for (int i = 0; i < pathArray.Length; i++) { ScriptableObject sobj = Resources.Load <ScriptableObject>(pathArray[i]); if (sobj != null) { window.assetList.Add(sobj); } } } }