Пример #1
0
        public static void CreateNoticeWordsAsset()
        {
            NoticeWordsManager manager = ScriptableObject.CreateInstance <NoticeWordsManager>();

            //赋值
            manager.dataArray = ExcelTool.CreateNoticeWordsArrayWithExcel(ExcelConfig.excelsFolderPath + "noticewords.xlsx");

            //确保文件夹存在
            if (!Directory.Exists(ExcelConfig.assetPath))
            {
                Directory.CreateDirectory(ExcelConfig.assetPath);
            }

            //asset文件的路径 要以"Assets/..."开始,否则CreateAsset会报错
            string assetPath = string.Format("{0}{1}.asset", ExcelConfig.assetPath, "NoticeWords");

            //生成一个Asset文件
            AssetDatabase.CreateAsset(manager, assetPath);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }