111
This commit is contained in:
@@ -9,12 +9,20 @@ using UnityEngine;
|
|||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
using Sirenix.OdinInspector.Editor;
|
using Sirenix.OdinInspector.Editor;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Stary.Evo.TableTextConversion;
|
using Stary.Evo.TableTextConversion;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
namespace Stary.Evo.TableTextConversion
|
namespace Stary.Evo.TableTextConversion
|
||||||
{
|
{
|
||||||
public class ConvertedExslDataMessage : OdinEditorWindow
|
public class ConvertedExslDataMessage : OdinEditorWindow
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 配置文件类型
|
||||||
|
/// </summary>
|
||||||
|
[EnumToggleButtons, HideLabel] [OnValueChanged("SetConfigurationFileType")]
|
||||||
|
public ConfigurationFileType configurationFileType = ConfigurationFileType.Asset;
|
||||||
|
|
||||||
private static ConvertedExslDataMessage window;
|
private static ConvertedExslDataMessage window;
|
||||||
|
|
||||||
// 读取的位置
|
// 读取的位置
|
||||||
@@ -33,6 +41,12 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
window.Show();
|
window.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
configurationFileType = (ConfigurationFileType)Enum.Parse(typeof(ConfigurationFileType),
|
||||||
|
EditorPrefs.GetString("ConfigurationFileType"));
|
||||||
|
}
|
||||||
|
|
||||||
[Title("转化配置的Exsl文件:", titleAlignment: TitleAlignments.Centered)]
|
[Title("转化配置的Exsl文件:", titleAlignment: TitleAlignments.Centered)]
|
||||||
[HorizontalGroup("BuildPipeline"), HideLabel]
|
[HorizontalGroup("BuildPipeline"), HideLabel]
|
||||||
@@ -50,7 +64,7 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
|
|
||||||
//[MenuItem("Exsl/信息表转换")]
|
//[MenuItem("Exsl/信息表转换")]
|
||||||
[Button("转化Exsl表格", ButtonSizes.Large)]
|
[Button("转化Exsl表格", ButtonSizes.Large)]
|
||||||
public static void CrtateMessage()
|
public void CrtateMessage()
|
||||||
{
|
{
|
||||||
#region 读取Excel表格并转成DataSet类型的数据
|
#region 读取Excel表格并转成DataSet类型的数据
|
||||||
|
|
||||||
@@ -112,10 +126,10 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
{
|
{
|
||||||
#region 遍历表格相应的数据转换成数据
|
#region 遍历表格相应的数据转换成数据
|
||||||
|
|
||||||
List<AudioTableData.MessageInfo> messageInfos = new List<AudioTableData.MessageInfo>();
|
List<AudioEntity> messageInfos = new List<AudioEntity>();
|
||||||
for (int j = 1; j < VoiceCount; j++)
|
for (int j = 1; j < VoiceCount; j++)
|
||||||
{
|
{
|
||||||
AudioTableData.MessageInfo messageInfo = new AudioTableData.MessageInfo();
|
AudioEntity messageInfo = new AudioEntity();
|
||||||
//获取对话块
|
//获取对话块
|
||||||
messageInfo.index = j - 1;
|
messageInfo.index = j - 1;
|
||||||
//文件名称
|
//文件名称
|
||||||
@@ -123,16 +137,16 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
//获取内容
|
//获取内容
|
||||||
messageInfo.autype =
|
messageInfo.autype =
|
||||||
Enum.TryParse(FilterTo(table.Rows[j][1].ToString()),
|
Enum.TryParse(FilterTo(table.Rows[j][1].ToString()),
|
||||||
out AudioTableData.AudioType auType)
|
out AudioType auType)
|
||||||
? auType
|
? auType
|
||||||
: AudioTableData.AudioType.Null;
|
: AudioType.Null;
|
||||||
|
|
||||||
//获取描述
|
//获取描述
|
||||||
messageInfo.filename = FilterTo(table.Rows[j][2].ToString());
|
messageInfo.filename = FilterTo(table.Rows[j][2].ToString());
|
||||||
|
|
||||||
messageInfo.voice = FilterTo(table.Rows[j][3].ToString());
|
messageInfo.voice = FilterTo(table.Rows[j][3].ToString());
|
||||||
|
|
||||||
|
|
||||||
messageInfo.uirelated = FilterTo(table.Rows[j][4].ToString());
|
messageInfo.uirelated = FilterTo(table.Rows[j][4].ToString());
|
||||||
//添加数据
|
//添加数据
|
||||||
messageInfos.Add(messageInfo);
|
messageInfos.Add(messageInfo);
|
||||||
@@ -140,11 +154,18 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
ScriptObjectSave<AudioTableData>("AudioTableData", (data) =>
|
if (configurationFileType == ConfigurationFileType.Asset)
|
||||||
{
|
{
|
||||||
data.infos = new List<AudioTableData.MessageInfo>();
|
ScriptObjectSave<AudioTableData>("AudioTableData", (data) =>
|
||||||
data.infos = messageInfos;
|
{
|
||||||
});
|
data.infos = new List<AudioEntity>();
|
||||||
|
data.infos = messageInfos;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (configurationFileType == ConfigurationFileType.Json)
|
||||||
|
{
|
||||||
|
JsonSave<List<AudioEntity>>("AudioTableData", () => { return messageInfos; });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -155,10 +176,10 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
{
|
{
|
||||||
#region 遍历表格相应的数据转换成数据
|
#region 遍历表格相应的数据转换成数据
|
||||||
|
|
||||||
List<VideoTableData.MessageInfo> messageInfos = new List<VideoTableData.MessageInfo>();
|
List<VideoEntity> messageInfos = new List<VideoEntity>();
|
||||||
for (int j = 1; j < VoiceCount; j++)
|
for (int j = 1; j < VoiceCount; j++)
|
||||||
{
|
{
|
||||||
VideoTableData.MessageInfo messageInfo = new VideoTableData.MessageInfo();
|
VideoEntity messageInfo = new VideoEntity();
|
||||||
//获取对话块
|
//获取对话块
|
||||||
messageInfo.index = j - 1;
|
messageInfo.index = j - 1;
|
||||||
//文件名称
|
//文件名称
|
||||||
@@ -179,19 +200,27 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
? true
|
? true
|
||||||
: false;
|
: false;
|
||||||
messageInfo.videoframeName = FilterTo(table.Rows[j][6].ToString());
|
messageInfo.videoframeName = FilterTo(table.Rows[j][6].ToString());
|
||||||
|
|
||||||
|
|
||||||
//添加数据
|
//添加数据
|
||||||
messageInfos.Add(messageInfo);
|
messageInfos.Add(messageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
ScriptObjectSave<VideoTableData>("VideoTableData", (data) =>
|
|
||||||
|
if (configurationFileType == ConfigurationFileType.Asset)
|
||||||
{
|
{
|
||||||
data.infos = new List<VideoTableData.MessageInfo>();
|
ScriptObjectSave<VideoTableData>("VideoTableData", (data) =>
|
||||||
data.infos = messageInfos;
|
{
|
||||||
});
|
data.infos = new List<VideoEntity>();
|
||||||
|
data.infos = messageInfos;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (configurationFileType == ConfigurationFileType.Json)
|
||||||
|
{
|
||||||
|
JsonSave<List<VideoEntity>>("VideoTableData", () => { return messageInfos; });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -202,9 +231,9 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
{
|
{
|
||||||
#region 遍历表格相应的数据转换成数据
|
#region 遍历表格相应的数据转换成数据
|
||||||
|
|
||||||
List<UITableData.MessageInfo> messageInfos = new List<UITableData.MessageInfo>();
|
List<UIEntity> messageInfos = new List<UIEntity>();
|
||||||
UITableData.MessageInfo messageInfo = null;
|
UIEntity messageInfo = null;
|
||||||
List<UITableData.SubtitleInfo> subtitle = null;
|
List<SubtitleInfo> subtitle = null;
|
||||||
int infoIndex = 0;
|
int infoIndex = 0;
|
||||||
for (int j = 1; j < VoiceCount; j++)
|
for (int j = 1; j < VoiceCount; j++)
|
||||||
{
|
{
|
||||||
@@ -212,8 +241,8 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
if (!table.Rows[j][0].ToString().Equals(""))
|
if (!table.Rows[j][0].ToString().Equals(""))
|
||||||
{
|
{
|
||||||
Debug.Log(table.Rows[j][0].ToString());
|
Debug.Log(table.Rows[j][0].ToString());
|
||||||
messageInfo = new UITableData.MessageInfo();
|
messageInfo = new UIEntity();
|
||||||
subtitle = new List<UITableData.SubtitleInfo>();
|
subtitle = new List<SubtitleInfo>();
|
||||||
messageInfo.subtitle = subtitle;
|
messageInfo.subtitle = subtitle;
|
||||||
//获取对话块
|
//获取对话块
|
||||||
messageInfo.index = infoIndex;
|
messageInfo.index = infoIndex;
|
||||||
@@ -227,7 +256,7 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
|
|
||||||
if (!table.Rows[j][3].ToString().Equals(""))
|
if (!table.Rows[j][3].ToString().Equals(""))
|
||||||
{
|
{
|
||||||
var subtitleInfo = new UITableData.SubtitleInfo();
|
var subtitleInfo = new SubtitleInfo();
|
||||||
subtitleInfo.lineid = FilterTo(table.Rows[j][3].ToString());
|
subtitleInfo.lineid = FilterTo(table.Rows[j][3].ToString());
|
||||||
subtitleInfo.subtitle = FilterTo(table.Rows[j][4].ToString());
|
subtitleInfo.subtitle = FilterTo(table.Rows[j][4].ToString());
|
||||||
subtitleInfo.start =
|
subtitleInfo.start =
|
||||||
@@ -242,7 +271,7 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
messageInfo.subtitle.Add(subtitleInfo);
|
messageInfo.subtitle.Add(subtitleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//添加数据
|
//添加数据
|
||||||
messageInfos.Add(messageInfo);
|
messageInfos.Add(messageInfo);
|
||||||
infoIndex++;
|
infoIndex++;
|
||||||
@@ -251,7 +280,7 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
{
|
{
|
||||||
if (!table.Rows[j][3].ToString().Equals(""))
|
if (!table.Rows[j][3].ToString().Equals(""))
|
||||||
{
|
{
|
||||||
var subtitleInfo = new UITableData.SubtitleInfo();
|
var subtitleInfo = new SubtitleInfo();
|
||||||
subtitleInfo.lineid = FilterTo(table.Rows[j][3].ToString());
|
subtitleInfo.lineid = FilterTo(table.Rows[j][3].ToString());
|
||||||
subtitleInfo.subtitle = FilterTo(table.Rows[j][4].ToString());
|
subtitleInfo.subtitle = FilterTo(table.Rows[j][4].ToString());
|
||||||
subtitleInfo.start =
|
subtitleInfo.start =
|
||||||
@@ -270,11 +299,18 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
ScriptObjectSave<UITableData>("UITableData", (data) =>
|
if (configurationFileType == ConfigurationFileType.Asset)
|
||||||
{
|
{
|
||||||
data.infos = new List<UITableData.MessageInfo>();
|
ScriptObjectSave<UITableData>("UITableData", (data) =>
|
||||||
data.infos = messageInfos;
|
{
|
||||||
});
|
data.infos = new List<UIEntity>();
|
||||||
|
data.infos = messageInfos;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (configurationFileType == ConfigurationFileType.Json)
|
||||||
|
{
|
||||||
|
JsonSave<List<UIEntity>>("UITableData", () => { return messageInfos; });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -322,6 +358,39 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
AssetDatabase.Refresh();
|
AssetDatabase.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ScriptObject数据保存类
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetName"></param>
|
||||||
|
/// <param name="action">写入数据的一个回调</param>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
private static void JsonSave<T>(string assetName, Func<T> func) where T : IEnumerable, new()
|
||||||
|
{
|
||||||
|
// 创建数据实例
|
||||||
|
T data = new T();
|
||||||
|
//放写入数据操作
|
||||||
|
data = func.Invoke();
|
||||||
|
// 确保保存目录存在
|
||||||
|
if (!Directory.Exists(Assetpath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(Assetpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建完整的保存路径
|
||||||
|
string jsonFilePath = Path.Combine(Assetpath, $"{assetName}.json");
|
||||||
|
|
||||||
|
// 序列化数据为JSON
|
||||||
|
string jsonContent = JsonConvert.SerializeObject(data, Formatting.Indented);
|
||||||
|
|
||||||
|
// 写入文件
|
||||||
|
File.WriteAllText(jsonFilePath, jsonContent);
|
||||||
|
|
||||||
|
// 刷新AssetDatabase
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
|
||||||
|
Debug.Log($"UnityEvo: JSON文件已保存到 {jsonFilePath}");
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -363,7 +432,7 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
string[] xlsxFiles = Directory.GetFiles(docFolderPath, "*.xlsx");
|
string[] xlsxFiles = Directory.GetFiles(docFolderPath, "*.xlsx");
|
||||||
|
|
||||||
result = xlsxFiles.Select(file => Path.GetFileNameWithoutExtension(file)).ToList();
|
result = xlsxFiles.Select(file => Path.GetFileNameWithoutExtension(file)).ToList();
|
||||||
|
selectedExslNames = EditorPrefs.GetString("BuildExslNames");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,15 +440,25 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
{
|
{
|
||||||
DocFolderPath = Path.Combine(GetDocFolderPath(), newValue + ".xlsx");
|
DocFolderPath = Path.Combine(GetDocFolderPath(), newValue + ".xlsx");
|
||||||
newDataName = newValue;
|
newDataName = newValue;
|
||||||
|
EditorPrefs.SetString("BuildExslNames", newDataName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取全部作用域名
|
/// 获取全部作用域名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static List<string> GetCreatDomainAllName()
|
public List<string> GetCreatDomainAllName()
|
||||||
{
|
{
|
||||||
string domainPath = $"{Application.dataPath}/Domain";
|
string domainPath = "";
|
||||||
|
if (configurationFileType == ConfigurationFileType.Asset)
|
||||||
|
{
|
||||||
|
domainPath = $"{Application.dataPath}/Domain";
|
||||||
|
}
|
||||||
|
else if (configurationFileType == ConfigurationFileType.Json)
|
||||||
|
{
|
||||||
|
domainPath = $"{Application.dataPath}/Modules";
|
||||||
|
}
|
||||||
|
|
||||||
string[] domains;
|
string[] domains;
|
||||||
// 新增目录获取代码
|
// 新增目录获取代码
|
||||||
if (Directory.Exists(domainPath))
|
if (Directory.Exists(domainPath))
|
||||||
@@ -395,12 +474,53 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
domains = Array.Empty<string>();
|
domains = Array.Empty<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return domains.Select(file => Path.GetFileNameWithoutExtension(file)).ToList();
|
if (configurationFileType == ConfigurationFileType.Asset)
|
||||||
|
{
|
||||||
|
selectedDomainNames = EditorPrefs.GetString("CurrentDomainName");
|
||||||
|
}
|
||||||
|
else if (configurationFileType == ConfigurationFileType.Json)
|
||||||
|
{
|
||||||
|
selectedDomainNames = EditorPrefs.GetString("CurrentModulesName");
|
||||||
|
}
|
||||||
|
|
||||||
|
return domains.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetCurrentDomainName(string newValue)
|
private void SetCurrentDomainName(string newValue)
|
||||||
{
|
{
|
||||||
Assetpath = Application.dataPath + "/Domain/" + newValue + "/AddressableRes/Config/";
|
if (configurationFileType == ConfigurationFileType.Asset)
|
||||||
|
{
|
||||||
|
Assetpath = Application.dataPath + "/Domain/" + newValue + "/AddressableRes/Config/";
|
||||||
|
EditorPrefs.SetString("CurrentDomainName", newValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Assetpath = Application.dataPath + "/Modules/" + newValue + "/Main/Res/Config/";
|
||||||
|
EditorPrefs.SetString("CurrentModulesName", newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Directory.Exists(Assetpath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(Assetpath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetConfigurationFileType()
|
||||||
|
{
|
||||||
|
EditorPrefs.SetString("ConfigurationFileType", configurationFileType.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ConfigurationFileType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// json类型
|
||||||
|
/// </summary>
|
||||||
|
Json,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// asset类型
|
||||||
|
/// </summary>
|
||||||
|
Asset
|
||||||
|
}
|
||||||
}
|
}
|
||||||
30
Assets/05.TableTextConversion/RunTime/Base/AudioEntity.cs
Normal file
30
Assets/05.TableTextConversion/RunTime/Base/AudioEntity.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using Sirenix.OdinInspector;
|
||||||
|
|
||||||
|
namespace Stary.Evo.TableTextConversion
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class AudioEntity
|
||||||
|
{
|
||||||
|
// 序号
|
||||||
|
[GUIColor(0, 1, 0)] public int index;
|
||||||
|
|
||||||
|
// 名称
|
||||||
|
public string auid;
|
||||||
|
|
||||||
|
public AudioType autype;
|
||||||
|
|
||||||
|
// 名称描述
|
||||||
|
public string filename;
|
||||||
|
public string voice;
|
||||||
|
public string uirelated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum AudioType
|
||||||
|
{
|
||||||
|
Null,
|
||||||
|
music,
|
||||||
|
effect,
|
||||||
|
sound,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a1a28b6c544f4e939d68e56f08d87403
|
||||||
|
timeCreated: 1762855901
|
||||||
@@ -9,29 +9,6 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
public class AudioTableData : ScriptableObject, ITableData
|
public class AudioTableData : ScriptableObject, ITableData
|
||||||
{
|
{
|
||||||
public string TableName { get; }
|
public string TableName { get; }
|
||||||
public List<MessageInfo> infos;
|
public List<AudioEntity> infos;
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class MessageInfo
|
|
||||||
{
|
|
||||||
// 序号
|
|
||||||
[GUIColor(0, 1, 0)] public int index;
|
|
||||||
// 名称
|
|
||||||
public string auid;
|
|
||||||
public AudioType autype;
|
|
||||||
// 名称描述
|
|
||||||
public string filename;
|
|
||||||
public string voice;
|
|
||||||
public string uirelated;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum AudioType
|
|
||||||
{
|
|
||||||
Null,
|
|
||||||
music,
|
|
||||||
effect,
|
|
||||||
sound,
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
28
Assets/05.TableTextConversion/RunTime/Base/UIEntity.cs
Normal file
28
Assets/05.TableTextConversion/RunTime/Base/UIEntity.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Sirenix.OdinInspector;
|
||||||
|
|
||||||
|
namespace Stary.Evo.TableTextConversion
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class UIEntity
|
||||||
|
{
|
||||||
|
// 序号
|
||||||
|
[GUIColor(0, 1, 0)] public int index;
|
||||||
|
// 名称
|
||||||
|
public string uiid;
|
||||||
|
// 名称描述
|
||||||
|
public string filename;
|
||||||
|
|
||||||
|
public string uitype;
|
||||||
|
public List<SubtitleInfo> subtitle;
|
||||||
|
}
|
||||||
|
[Serializable]
|
||||||
|
public class SubtitleInfo
|
||||||
|
{
|
||||||
|
public string lineid;
|
||||||
|
public string subtitle;
|
||||||
|
public float start;
|
||||||
|
public float end;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: aa8c79fd9e99417abfdebb6ffa12629b
|
||||||
|
timeCreated: 1762855912
|
||||||
@@ -9,30 +9,7 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
public class UITableData : ScriptableObject, ITableData
|
public class UITableData : ScriptableObject, ITableData
|
||||||
{
|
{
|
||||||
public string TableName { get; }
|
public string TableName { get; }
|
||||||
public List<MessageInfo> infos;
|
public List<UIEntity> infos;
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class MessageInfo
|
|
||||||
{
|
|
||||||
// 序号
|
|
||||||
[GUIColor(0, 1, 0)] public int index;
|
|
||||||
// 名称
|
|
||||||
public string uiid;
|
|
||||||
// 名称描述
|
|
||||||
public string filename;
|
|
||||||
|
|
||||||
public string uitype;
|
|
||||||
public List<SubtitleInfo> subtitle;
|
|
||||||
|
|
||||||
}
|
|
||||||
[Serializable]
|
|
||||||
public class SubtitleInfo
|
|
||||||
{
|
|
||||||
public string lineid;
|
|
||||||
public string subtitle;
|
|
||||||
public float start;
|
|
||||||
public float end;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
24
Assets/05.TableTextConversion/RunTime/Base/VideoEntity.cs
Normal file
24
Assets/05.TableTextConversion/RunTime/Base/VideoEntity.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using Sirenix.OdinInspector;
|
||||||
|
|
||||||
|
namespace Stary.Evo.TableTextConversion
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class VideoEntity
|
||||||
|
{
|
||||||
|
// 序号
|
||||||
|
[GUIColor(0, 1, 0)] public int index;
|
||||||
|
|
||||||
|
// 名称
|
||||||
|
public string vidid;
|
||||||
|
|
||||||
|
// 名称描述
|
||||||
|
public string filename;
|
||||||
|
public string vidtype;
|
||||||
|
|
||||||
|
public string location;
|
||||||
|
public float time;
|
||||||
|
public bool subtitle;
|
||||||
|
public string videoframeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f6b98bb6dbce4f999d0ca6d2d08f6900
|
||||||
|
timeCreated: 1762855926
|
||||||
@@ -9,27 +9,7 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
public class VideoTableData : ScriptableObject, ITableData
|
public class VideoTableData : ScriptableObject, ITableData
|
||||||
{
|
{
|
||||||
public string TableName { get; }
|
public string TableName { get; }
|
||||||
public List<MessageInfo> infos;
|
public List<VideoEntity> infos;
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class MessageInfo
|
|
||||||
{
|
|
||||||
// 序号
|
|
||||||
[GUIColor(0, 1, 0)] public int index;
|
|
||||||
// 名称
|
|
||||||
public string vidid;
|
|
||||||
// 名称描述
|
|
||||||
public string filename;
|
|
||||||
public string vidtype;
|
|
||||||
|
|
||||||
public string location;
|
|
||||||
public float time;
|
|
||||||
public bool subtitle;
|
|
||||||
public string videoframeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,14 +7,14 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
{
|
{
|
||||||
public interface IAudioTableDataCore : ITableDataCore
|
public interface IAudioTableDataCore : ITableDataCore
|
||||||
{
|
{
|
||||||
UniTask<Stary.Evo.TableTextConversion.AudioTableData.MessageInfo> GetAudioInfo(string auid);
|
UniTask<AudioEntity> GetAudioAssetInfo(string auid);
|
||||||
UniTask<AudioClip> GetAudioClip(string auid);
|
UniTask<AudioClip> GetAudioAssetClip(string auid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if YooAssets
|
||||||
public class AudioTableDataCore : IAudioTableDataCore, IDisposable
|
public class AudioTableDataCore : IAudioTableDataCore, IDisposable
|
||||||
{
|
{
|
||||||
private Stary.Evo.TableTextConversion.AudioTableData audioTableData;
|
private AudioTableData audioTableData;
|
||||||
|
|
||||||
public string TableName => "Config_AudioTableData";
|
public string TableName => "Config_AudioTableData";
|
||||||
public bool IsLoad { get; set; }
|
public bool IsLoad { get; set; }
|
||||||
@@ -23,14 +23,15 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
public async UniTask LoadData()
|
public async UniTask LoadData()
|
||||||
{
|
{
|
||||||
var audioHandle =
|
var audioHandle =
|
||||||
YooAssets.LoadAssetAsync<Stary.Evo.TableTextConversion.AudioTableData>(TableName);
|
YooAssets.LoadAssetAsync<AudioTableData>(TableName);
|
||||||
await audioHandle.Task;
|
await audioHandle.Task;
|
||||||
audioTableData = audioHandle.GetAssetObject<Stary.Evo.TableTextConversion.AudioTableData>();
|
audioTableData = audioHandle.GetAssetObject<AudioTableData>();
|
||||||
if (audioTableData == null)
|
if (audioTableData == null)
|
||||||
{
|
{
|
||||||
Debug.LogError($"加载音频表失败,请排查config下是否存在【{TableName}】表");
|
Debug.LogError($"加载音频表失败,请排查config下是否存在【{TableName}】表");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsLoad = true;
|
IsLoad = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="auid"></param>
|
/// <param name="auid"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async UniTask<Stary.Evo.TableTextConversion.AudioTableData.MessageInfo> GetAudioInfo(string auid)
|
public async UniTask<AudioEntity> GetAudioAssetInfo(string auid)
|
||||||
{
|
{
|
||||||
if (!IsLoad)
|
if (!IsLoad)
|
||||||
{
|
{
|
||||||
@@ -61,14 +62,14 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="auid"></param>
|
/// <param name="auid"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async UniTask<AudioClip> GetAudioClip(string auid)
|
public async UniTask<AudioClip> GetAudioAssetClip(string auid)
|
||||||
{
|
{
|
||||||
if (!IsLoad)
|
if (!IsLoad)
|
||||||
{
|
{
|
||||||
await LoadData();
|
await LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
var info = await GetAudioInfo(auid);
|
var info = await GetAudioAssetInfo(auid);
|
||||||
var handle = YooAssets.LoadAssetAsync<AudioClip>(info.filename);
|
var handle = YooAssets.LoadAssetAsync<AudioClip>(info.filename);
|
||||||
await handle.Task;
|
await handle.Task;
|
||||||
if (handle.Status == EOperationStatus.Succeed)
|
if (handle.Status == EOperationStatus.Succeed)
|
||||||
@@ -89,4 +90,5 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
audioTableData = null;
|
audioTableData = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
public IAudioTableDataCore AudioTableCore;
|
public IAudioTableDataCore AudioTableCore;
|
||||||
public IUITableDataCore UITableCore;
|
public IUITableDataCore UITableCore;
|
||||||
public IVideoTableDataCore VideoTableCore;
|
public IVideoTableDataCore VideoTableCore;
|
||||||
|
#if YooAssets
|
||||||
// 私有构造函数,防止外部实例化
|
// 私有构造函数,防止外部实例化
|
||||||
private TableSystem()
|
private TableSystem()
|
||||||
{
|
{
|
||||||
@@ -32,6 +32,7 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
UITableCore = new UITableDataCore();
|
UITableCore = new UITableDataCore();
|
||||||
VideoTableCore = new VideoTableDataCore();
|
VideoTableCore = new VideoTableDataCore();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
{
|
{
|
||||||
public interface IUITableDataCore : ITableDataCore
|
public interface IUITableDataCore : ITableDataCore
|
||||||
{
|
{
|
||||||
UniTask<Stary.Evo.TableTextConversion.UITableData.MessageInfo> GetUIInfo(string uiid);
|
UniTask<UIEntity> GetUIAssetInfo(string uiid);
|
||||||
UniTask<Sprite> GetSprite(string uiid);
|
UniTask<Sprite> GetSpriteAsset(string uiid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if YooAssets
|
||||||
public class UITableDataCore : IUITableDataCore, IDisposable
|
public class UITableDataCore : IUITableDataCore, IDisposable
|
||||||
{
|
{
|
||||||
public string TableName => "Config_UITableData";
|
public string TableName => "Config_UITableData";
|
||||||
@@ -21,9 +21,9 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
|
|
||||||
public async UniTask LoadData()
|
public async UniTask LoadData()
|
||||||
{
|
{
|
||||||
var handle = YooAssets.LoadAssetAsync<Stary.Evo.TableTextConversion.UITableData>(TableName);
|
var handle = YooAssets.LoadAssetAsync<UITableData>(TableName);
|
||||||
await handle.Task;
|
await handle.Task;
|
||||||
uiTableDatas = handle.GetAssetObject<Stary.Evo.TableTextConversion.UITableData>();
|
uiTableDatas = handle.GetAssetObject<UITableData>();
|
||||||
if (uiTableDatas == null)
|
if (uiTableDatas == null)
|
||||||
{
|
{
|
||||||
Debug.LogError($"加载UI表失败,请排查config下是否存在【{TableName}】表");
|
Debug.LogError($"加载UI表失败,请排查config下是否存在【{TableName}】表");
|
||||||
@@ -32,7 +32,7 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
IsLoad = true;
|
IsLoad = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async UniTask<Stary.Evo.TableTextConversion.UITableData.MessageInfo> GetUIInfo(string uiid)
|
public async UniTask<UIEntity> GetUIAssetInfo(string uiid)
|
||||||
{
|
{
|
||||||
if (!IsLoad)
|
if (!IsLoad)
|
||||||
{
|
{
|
||||||
@@ -48,14 +48,14 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async UniTask<Sprite> GetSprite(string uiid)
|
public async UniTask<Sprite> GetSpriteAsset(string uiid)
|
||||||
{
|
{
|
||||||
if (!IsLoad)
|
if (!IsLoad)
|
||||||
{
|
{
|
||||||
await LoadData();
|
await LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
var info = await GetUIInfo(uiid);
|
var info = await GetUIAssetInfo(uiid);
|
||||||
var handle = YooAssets.LoadAssetAsync<Sprite>(info.filename);
|
var handle = YooAssets.LoadAssetAsync<Sprite>(info.filename);
|
||||||
await handle.Task;
|
await handle.Task;
|
||||||
if (handle.Status == EOperationStatus.Succeed)
|
if (handle.Status == EOperationStatus.Succeed)
|
||||||
@@ -76,4 +76,5 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
uiTableDatas = null;
|
uiTableDatas = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
@@ -8,32 +8,33 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
public interface IVideoTableDataCore : ITableDataCore
|
public interface IVideoTableDataCore : ITableDataCore
|
||||||
{
|
{
|
||||||
UniTask LoadData();
|
UniTask LoadData();
|
||||||
UniTask<Stary.Evo.TableTextConversion.VideoTableData.MessageInfo> PlayVideoName(string vidid);
|
UniTask<VideoEntity> PlayVideoAssetName(string vidid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if YooAssets
|
||||||
public class VideoTableDataCore : IVideoTableDataCore, IDisposable
|
public class VideoTableDataCore : IVideoTableDataCore, IDisposable
|
||||||
{
|
{
|
||||||
public string TableName => "Config_VideoTableData";
|
public string TableName => "Config_VideoTableData";
|
||||||
public bool IsLoad { get; set; }
|
public bool IsLoad { get; set; }
|
||||||
private Stary.Evo.TableTextConversion.VideoTableData videoTableDatas;
|
private VideoTableData videoTableDatas;
|
||||||
|
|
||||||
|
|
||||||
public async UniTask LoadData()
|
public async UniTask LoadData()
|
||||||
{
|
{
|
||||||
var handle = YooAssets.LoadAssetAsync<Stary.Evo.TableTextConversion.VideoTableData>(TableName);
|
var handle = YooAssets.LoadAssetAsync<VideoTableData>(TableName);
|
||||||
await handle.Task;
|
await handle.Task;
|
||||||
videoTableDatas = handle.GetAssetObject<Stary.Evo.TableTextConversion.VideoTableData>();
|
videoTableDatas = handle.GetAssetObject<VideoTableData>();
|
||||||
if (videoTableDatas == null)
|
if (videoTableDatas == null)
|
||||||
{
|
{
|
||||||
Debug.LogError($"加载视频表失败,请排查config下是否存在【{TableName}】表");
|
Debug.LogError($"加载视频表失败,请排查config下是否存在【{TableName}】表");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsLoad = true;
|
IsLoad = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async UniTask<Stary.Evo.TableTextConversion.VideoTableData.MessageInfo> PlayVideoName(string vidid)
|
public async UniTask<VideoEntity> PlayVideoAssetName(string vidid)
|
||||||
{
|
{
|
||||||
if (!IsLoad)
|
if (!IsLoad)
|
||||||
{
|
{
|
||||||
@@ -59,4 +60,5 @@ namespace Stary.Evo.TableTextConversion
|
|||||||
videoTableDatas = null;
|
videoTableDatas = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "com.staryevo.tabletextconversion",
|
"name": "com.staryevo.tabletextconversion",
|
||||||
"version": "2.0.3",
|
"version": "2.0.4",
|
||||||
"displayName": "05.TableTextConversion",
|
"displayName": "05.TableTextConversion",
|
||||||
"description": "表格转化工具",
|
"description": "表格转化工具",
|
||||||
"unity": "2021.3",
|
"unity": "2021.3",
|
||||||
|
|||||||
Reference in New Issue
Block a user