05 table 更新
This commit is contained in:
@@ -22,7 +22,7 @@ namespace Stary.Evo.TableTextConversion
|
||||
|
||||
// 生成配置文件的位置
|
||||
private static string Assetpath;
|
||||
|
||||
|
||||
// 转化表的名称
|
||||
private static string newDataName;
|
||||
|
||||
@@ -77,68 +77,115 @@ namespace Stary.Evo.TableTextConversion
|
||||
Debug.LogError("UnityEvo:生成配置文件的位置不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
FileStream stream = File.Open(DocFolderPath, FileMode.Open, FileAccess.Read);
|
||||
IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
|
||||
//获取结果
|
||||
DataSet result = excelReader.AsDataSet();
|
||||
|
||||
int oneRows = result.Tables[0].Rows.Count; //行数
|
||||
|
||||
Dictionary<int, int> dict_Question = new Dictionary<int, int>();
|
||||
Dictionary<int, int> dict_Menu = new Dictionary<int, int>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region 通过遍历一遍表格所有行的第一列【序号】不为空
|
||||
|
||||
int VoiceCount = 0;
|
||||
for (int i = 0; i < oneRows; i++)
|
||||
if (result.Tables.Count > 0)
|
||||
{
|
||||
string key = FilterTo(result.Tables[0].Rows[i][0].ToString());
|
||||
if (!string.IsNullOrEmpty(key))
|
||||
for (int i = 0; i < result.Tables.Count; i++)
|
||||
{
|
||||
VoiceCount++;
|
||||
//开始遍历说有table表
|
||||
int oneRows = result.Tables[i].Rows.Count; //行数
|
||||
Dictionary<int, int> dict_Question = new Dictionary<int, int>();
|
||||
Dictionary<int, int> dict_Menu = new Dictionary<int, int>();
|
||||
|
||||
#region 通过遍历一遍表格所有行的第一列【序号】不为空
|
||||
|
||||
int VoiceCount = 0;
|
||||
for (int j = 0; j < oneRows; j++)
|
||||
{
|
||||
string key = FilterTo(result.Tables[i].Rows[j][0].ToString());
|
||||
if (!string.IsNullOrEmpty(key))
|
||||
{
|
||||
VoiceCount++;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AudioTableData
|
||||
|
||||
if (result.Tables[i].TableName == "audio")
|
||||
{
|
||||
#region 遍历表格相应的数据转换成数据
|
||||
|
||||
List<AudioTableData.MessageInfo> messageInfos = new List<AudioTableData.MessageInfo>();
|
||||
for (int j = 1; j < VoiceCount; j++)
|
||||
{
|
||||
AudioTableData.MessageInfo messageInfo = new AudioTableData.MessageInfo();
|
||||
//获取对话块
|
||||
messageInfo.index = j - 1;
|
||||
//文件名称
|
||||
messageInfo.auId = FilterTo(result.Tables[i].Rows[j][0].ToString());
|
||||
//获取内容
|
||||
messageInfo.fileName = FilterTo(result.Tables[i].Rows[j][1].ToString());
|
||||
|
||||
//获取描述
|
||||
messageInfo.auType = Enum.TryParse(FilterTo(result.Tables[i].Rows[j][2].ToString()), out AudioTableData.AudioType auType)? auType : AudioTableData.AudioType.Null;
|
||||
|
||||
messageInfo.lineId = int.TryParse(FilterTo(result.Tables[i].Rows[j][3].ToString()), out int line) ? line : 0;
|
||||
|
||||
messageInfo.startTime = float.TryParse(FilterTo(result.Tables[i].Rows[j][4].ToString()), out float start) ? start : 0;
|
||||
messageInfo.endTime = float.TryParse(FilterTo(result.Tables[i].Rows[j][5].ToString()), out float end) ? end : 0;
|
||||
messageInfo.text = FilterTo(result.Tables[i].Rows[j][6].ToString());
|
||||
//添加数据
|
||||
messageInfos.Add(messageInfo);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
ScriptObjectSave<AudioTableData>("AudioTableData", (data) =>
|
||||
{
|
||||
data.infos = new List<AudioTableData.MessageInfo>();
|
||||
data.infos = messageInfos;
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region AudioTableData
|
||||
|
||||
if (result.Tables[i].TableName == "video")
|
||||
{
|
||||
#region 遍历表格相应的数据转换成数据
|
||||
|
||||
List<VideoTableData.MessageInfo> messageInfos = new List<VideoTableData.MessageInfo>();
|
||||
for (int j = 1; j < VoiceCount; j++)
|
||||
{
|
||||
VideoTableData.MessageInfo messageInfo = new VideoTableData.MessageInfo();
|
||||
//获取对话块
|
||||
messageInfo.index = j - 1;
|
||||
//文件名称
|
||||
messageInfo.vId = FilterTo(result.Tables[i].Rows[j][0].ToString());
|
||||
//获取内容
|
||||
messageInfo.fileName = FilterTo(result.Tables[i].Rows[j][1].ToString());
|
||||
|
||||
//获取描述
|
||||
messageInfo.vType = FilterTo(result.Tables[i].Rows[j][2].ToString());
|
||||
|
||||
messageInfo.location = FilterTo(result.Tables[i].Rows[j][3].ToString());
|
||||
|
||||
messageInfo.time = float.TryParse(FilterTo(result.Tables[i].Rows[j][4].ToString()), out float start) ? start : 0;
|
||||
messageInfo.subtitle = FilterTo(result.Tables[i].Rows[j][5].ToString()).Equals("是")? true : false;
|
||||
messageInfo.remark = FilterTo(result.Tables[i].Rows[j][6].ToString());
|
||||
//添加数据
|
||||
messageInfos.Add(messageInfo);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
ScriptObjectSave<VideoTableData>("VideoTableData", (data) =>
|
||||
{
|
||||
data.infos = new List<VideoTableData.MessageInfo>();
|
||||
data.infos = messageInfos;
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// 条件判断
|
||||
/*if (newDataName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if(newDataName == "")
|
||||
{
|
||||
|
||||
}*/
|
||||
#region AudioTableData
|
||||
|
||||
#region 遍历表格相应的数据转换成数据
|
||||
|
||||
List<AudioTableData.MessageInfo> messageInfos = new List<AudioTableData.MessageInfo>();
|
||||
for (int i = 1; i < VoiceCount; i++)
|
||||
{
|
||||
AudioTableData.MessageInfo messageInfo = new AudioTableData.MessageInfo();
|
||||
//获取对话块
|
||||
messageInfo.index = i - 1;
|
||||
//文件名称
|
||||
messageInfo.name = FilterTo(result.Tables[0].Rows[i][0].ToString());
|
||||
//获取内容
|
||||
messageInfo.nameMessage = FilterTo(result.Tables[0].Rows[i][1].ToString());
|
||||
//添加数据
|
||||
messageInfos.Add(messageInfo);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
ScriptObjectSave<AudioTableData>("AudioTableData", (data) =>
|
||||
{
|
||||
data.infos = new List<AudioTableData.MessageInfo>();
|
||||
data.infos = messageInfos;
|
||||
});
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user