private static void ToScriptableObject(string sheetName, string outputPath, SheetData sheetData) { try { var dataTableClassName = EESettings.Current.GetDataTableClassName(sheetName); var asset = ScriptableObject.CreateInstance(dataTableClassName); var dataCollect = asset as RowDataCollection; if (dataCollect == null) { return; } var className = EESettings.Current.GetRowDataClassName(sheetName, true); var dataType = Type.GetType(className); if (dataType == null) { var asmb = Assembly.LoadFrom(Environment.CurrentDirectory + "/Library/ScriptAssemblies/Assembly-CSharp.dll"); dataType = asmb.GetType(className); } if (dataType == null) { EELog.LogError(className + " not exist !"); return; } var dataCtor = dataType.GetConstructor(Type.EmptyTypes); if (dataCtor == null) { return; } var ids = new HashSet <int>(); for (var row = EESettings.Current.DataStartIndex; row < sheetData.rowCount; ++row) { for (var col = 0; col < sheetData.columnCount; ++col) { sheetData.Set(row, col, sheetData.Get(row, col).Replace("\n", "\\n")); } var inst = dataCtor.Invoke(null) as RowData; if (inst == null) { continue; } inst._init(sheetData.Table, row, 0); if (!ids.Contains(inst.ID)) { dataCollect.AddData(inst); ids.Add(inst.ID); } else { EELog.LogWarning("More than one rows use ID " + inst.ID + " in " + sheetName); } } var itemPath = outputPath + EESettings.GetAssetFileName(sheetName); itemPath = itemPath.Substring(itemPath.IndexOf("Assets", StringComparison.Ordinal)); AssetDatabase.CreateAsset(asset, itemPath); AssetDatabase.Refresh(); } catch (Exception ex) { EELog.LogError(ex.ToString()); } }