05 table 更新
This commit is contained in:
@@ -77,24 +77,26 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
Debug.LogError("UnityEvo:生成配置文件的位置不存在");
|
Debug.LogError("UnityEvo:生成配置文件的位置不存在");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStream stream = File.Open(DocFolderPath, FileMode.Open, FileAccess.Read);
|
FileStream stream = File.Open(DocFolderPath, FileMode.Open, FileAccess.Read);
|
||||||
IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
|
IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
|
||||||
//获取结果
|
//获取结果
|
||||||
DataSet result = excelReader.AsDataSet();
|
DataSet result = excelReader.AsDataSet();
|
||||||
|
if (result.Tables.Count > 0)
|
||||||
int oneRows = result.Tables[0].Rows.Count; //行数
|
{
|
||||||
|
for (int i = 0; i < result.Tables.Count; i++)
|
||||||
|
{
|
||||||
|
//开始遍历说有table表
|
||||||
|
int oneRows = result.Tables[i].Rows.Count; //行数
|
||||||
Dictionary<int, int> dict_Question = new Dictionary<int, int>();
|
Dictionary<int, int> dict_Question = new Dictionary<int, int>();
|
||||||
Dictionary<int, int> dict_Menu = new Dictionary<int, int>();
|
Dictionary<int, int> dict_Menu = new Dictionary<int, int>();
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 通过遍历一遍表格所有行的第一列【序号】不为空
|
#region 通过遍历一遍表格所有行的第一列【序号】不为空
|
||||||
|
|
||||||
int VoiceCount = 0;
|
int VoiceCount = 0;
|
||||||
for (int i = 0; i < oneRows; i++)
|
for (int j = 0; j < oneRows; j++)
|
||||||
{
|
{
|
||||||
string key = FilterTo(result.Tables[0].Rows[i][0].ToString());
|
string key = FilterTo(result.Tables[i].Rows[j][0].ToString());
|
||||||
if (!string.IsNullOrEmpty(key))
|
if (!string.IsNullOrEmpty(key))
|
||||||
{
|
{
|
||||||
VoiceCount++;
|
VoiceCount++;
|
||||||
@@ -103,29 +105,31 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// 条件判断
|
|
||||||
/*if (newDataName == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if(newDataName == "")
|
|
||||||
{
|
|
||||||
|
|
||||||
}*/
|
|
||||||
#region AudioTableData
|
#region AudioTableData
|
||||||
|
|
||||||
|
if (result.Tables[i].TableName == "audio")
|
||||||
|
{
|
||||||
#region 遍历表格相应的数据转换成数据
|
#region 遍历表格相应的数据转换成数据
|
||||||
|
|
||||||
List<AudioTableData.MessageInfo> messageInfos = new List<AudioTableData.MessageInfo>();
|
List<AudioTableData.MessageInfo> messageInfos = new List<AudioTableData.MessageInfo>();
|
||||||
for (int i = 1; i < VoiceCount; i++)
|
for (int j = 1; j < VoiceCount; j++)
|
||||||
{
|
{
|
||||||
AudioTableData.MessageInfo messageInfo = new AudioTableData.MessageInfo();
|
AudioTableData.MessageInfo messageInfo = new AudioTableData.MessageInfo();
|
||||||
//获取对话块
|
//获取对话块
|
||||||
messageInfo.index = i - 1;
|
messageInfo.index = j - 1;
|
||||||
//文件名称
|
//文件名称
|
||||||
messageInfo.name = FilterTo(result.Tables[0].Rows[i][0].ToString());
|
messageInfo.auId = FilterTo(result.Tables[i].Rows[j][0].ToString());
|
||||||
//获取内容
|
//获取内容
|
||||||
messageInfo.nameMessage = FilterTo(result.Tables[0].Rows[i][1].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);
|
messageInfos.Add(messageInfo);
|
||||||
}
|
}
|
||||||
@@ -137,8 +141,51 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
data.infos = new List<AudioTableData.MessageInfo>();
|
data.infos = new List<AudioTableData.MessageInfo>();
|
||||||
data.infos = messageInfos;
|
data.infos = messageInfos;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -17,9 +17,23 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
// 序号
|
// 序号
|
||||||
[GUIColor(0, 1, 0)] public int index;
|
[GUIColor(0, 1, 0)] public int index;
|
||||||
// 名称
|
// 名称
|
||||||
public string name;
|
public string auId;
|
||||||
// 名称描述
|
// 名称描述
|
||||||
public string nameMessage;
|
public string fileName;
|
||||||
}
|
public AudioType auType;
|
||||||
|
public int lineId;
|
||||||
|
public float startTime;
|
||||||
|
public float endTime;
|
||||||
|
public string text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum AudioType
|
||||||
|
{
|
||||||
|
Null,
|
||||||
|
music,
|
||||||
|
effect,
|
||||||
|
sound,
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
33
Assets/05.TableTextConversion/RunTime/Base/VideoTableData.cs
Normal file
33
Assets/05.TableTextConversion/RunTime/Base/VideoTableData.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Sirenix.OdinInspector;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Stary.Evo.TableTextConversion
|
||||||
|
{
|
||||||
|
public class VideoTableData : ScriptableObject, ITableData
|
||||||
|
{
|
||||||
|
public string TableName { get; }
|
||||||
|
public List<MessageInfo> infos;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class MessageInfo
|
||||||
|
{
|
||||||
|
// 序号
|
||||||
|
[GUIColor(0, 1, 0)] public int index;
|
||||||
|
// 名称
|
||||||
|
public string vId;
|
||||||
|
// 名称描述
|
||||||
|
public string fileName;
|
||||||
|
public string vType;
|
||||||
|
public string location;
|
||||||
|
public float time;
|
||||||
|
public bool subtitle;
|
||||||
|
public string remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e14b39e2bfdb4587b6d8a7a49fe4d11e
|
||||||
|
timeCreated: 1745201406
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "com.staryevo.tabletextconversion",
|
"name": "com.staryevo.tabletextconversion",
|
||||||
"version": "1.0.4",
|
"version": "1.0.5",
|
||||||
"displayName": "05.TableTextConversion",
|
"displayName": "05.TableTextConversion",
|
||||||
"description": "表格转化工具",
|
"description": "表格转化工具",
|
||||||
"unity": "2021.3",
|
"unity": "2021.3",
|
||||||
|
|||||||
Reference in New Issue
Block a user