05 table 更新
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -17,9 +17,23 @@ namespace Stary.Evo.TableTextConversion
|
||||
// 序号
|
||||
[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",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.5",
|
||||
"displayName": "05.TableTextConversion",
|
||||
"description": "表格转化工具",
|
||||
"unity": "2021.3",
|
||||
|
||||
Reference in New Issue
Block a user