This commit is contained in:
Han
2025-04-01 18:26:48 +08:00
parent c3e2616c3a
commit ac499e2202
39 changed files with 1258 additions and 5 deletions

View File

@@ -0,0 +1,263 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.IO;
using Excel;
using UnityEditor;
using UnityEngine;
using Sirenix.OdinInspector;
using Sirenix.OdinInspector.Editor;
using System.Linq;
using Stary.Evo.TableTextConversion;
namespace Stary.Evo.TableTextConversion
{
public class ConvertedExslDataMessage : OdinEditorWindow
{
private static ConvertedExslDataMessage window;
// 读取的位置
private static string DocFolderPath;
// 生成配置文件的位置
private static string Assetpath;
// 转化表的名称
private static string newDataName;
[MenuItem("Exsl/信息表转换")]
static void ShowWindows()
{
window = (ConvertedExslDataMessage)EditorWindow.GetWindow(typeof(ConvertedExslDataMessage));
window.Show();
}
[Title("转化配置的Exsl文件", titleAlignment: TitleAlignments.Centered)]
[HorizontalGroup("BuildPipeline"), HideLabel]
[ValueDropdown("GetBuildExslNames")]
[OnValueChanged("SetBuildExslNames")]
public string selectedExslNames;
[Title("转化文件存储的作用域:", titleAlignment: TitleAlignments.Centered)]
[HorizontalGroup("BuildPipeline"), HideLabel]
[ValueDropdown("GetCreatDomainAllName")]
[OnValueChanged("SetCurrentDomainName")]
public string selectedDomainNames;
#region
//[MenuItem("Exsl/信息表转换")]
[Button("转化Exsl表格", ButtonSizes.Large)]
public static void CrtateMessage()
{
#region Excel表格并转成DataSet类型的数据
if (DocFolderPath == null)
{
Debug.LogError("UnityEvo:请先选择Exsl文件");
return;
}
if (Assetpath == null)
{
Debug.LogError("UnityEvo:请先选择生成配置文件的位置");
return;
}
/*if (!Directory.Exists(DocFolderPath))
{
Debug.LogError("UnityEvo:Exsl文件不存在");
return;
}*/
if (!Directory.Exists(Assetpath))
{
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++)
{
string key = FilterTo(result.Tables[0].Rows[i][0].ToString());
if (!string.IsNullOrEmpty(key))
{
VoiceCount++;
}
}
#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>
/// 过滤:去掉首尾空格和换行符【\n】
/// </summary>
private static string FilterTo(string self)
{
self = self.TrimStart();
self = self.TrimEnd();
self = self.Replace("\n", "");
return self;
}
/// <summary>
/// ScriptObject数据保存类
/// </summary>
/// <param name="assetName"></param>
/// <param name="action">写入数据的一个回调</param>
/// <typeparam name="T"></typeparam>
private static void ScriptObjectSave<T>(string assetName, Action<T> action) where T : ScriptableObject
{
string jsonPath = $"{Assetpath}{assetName}.asset";
if (File.Exists(jsonPath))
{
EditorFrameworkUtils.DeleteFile(Assetpath, assetName + ".asset");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
jsonPath = jsonPath.Substring(jsonPath.IndexOf("Assets"));
// Debug.Log($"要创建的为{jsonPath}");
var data = ScriptableObject.CreateInstance<T>();
//放写入数据操作
action.Invoke(data);
AssetDatabase.CreateAsset(data, jsonPath);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
#endregion
/// <summary>
/// 获取Doc文件夹的路径
/// </summary>
/// <returns></returns>
private string GetDocFolderPath()
{
// 获取 Assets 文件夹的路径
string assetsPath = Application.dataPath;
// 获取项目的根目录路径
string projectRootPath = Path.GetDirectoryName(assetsPath);
// 构造 Doc 文件夹的路径
string docFolderPath = Path.Combine(projectRootPath, "Doc");
return docFolderPath;
}
/// <summary>
/// 获取Doc文件夹下所有的Exsl名
/// </summary>
/// <returns></returns>
private List<string> GetBuildExslNames()
{
string docFolderPath = GetDocFolderPath();
// 检查 Doc 文件夹是否存在
if (!Directory.Exists(docFolderPath))
{
Debug.LogError($"UnityEvo:Doc 文件夹不存在,请检查路径:{docFolderPath}");
return null;
}
List<string> result = new List<string>();
// 遍历 Doc 文件夹中的所有 .xlsx 文件
string[] xlsxFiles = Directory.GetFiles(docFolderPath, "*.xlsx");
result = xlsxFiles.Select(file => Path.GetFileNameWithoutExtension(file)).ToList();
return result;
}
private void SetBuildExslNames(string newValue)
{
DocFolderPath = Path.Combine(GetDocFolderPath(), newValue + ".xlsx");
newDataName = newValue;
}
/// <summary>
/// 获取全部作用域名
/// </summary>
public static List<string> GetCreatDomainAllName()
{
string domainPath = $"{Application.dataPath}/Domain";
string[] domains;
// 新增目录获取代码
if (Directory.Exists(domainPath))
{
var dirInfo = new DirectoryInfo(domainPath);
// 获取直接子目录(不递归)
domains = dirInfo.GetDirectories("*", SearchOption.TopDirectoryOnly)
.Select(d => d.Name)
.ToArray();
}
else
{
domains = Array.Empty<string>();
}
return domains.Select(file => Path.GetFileNameWithoutExtension(file)).ToList();
}
private void SetCurrentDomainName(string newValue)
{
Assetpath = Application.dataPath + "/Domain/" + newValue + "/AddressableRes/Config/";
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ff5d8ff0135f01143b78a80fca9eb4cb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,482 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEngine;
namespace Stary.Evo.TableTextConversion
{
#if UNITY_EDITOR
/// <summary>
/// 文件辅助类
/// </summary>
public static class EditorFrameworkUtils
{
/// <summary>
/// 编码方式
/// </summary>
private static readonly Encoding Encoding = Encoding.UTF8;
/// <summary>
/// 递归取得文件夹下文件
/// </summary>
/// <param name="dir"></param>
/// <param name="list"></param>
public static void GetFiles(string dir, List<string> list)
{
GetFiles(dir, list, new List<string>());
}
/// <summary>
/// 递归取得文件夹下文件
/// </summary>
/// <param name="dir"></param>
/// <param name="list"></param>
/// <param name="fileExtsions"></param>
public static void GetFiles(string dir, List<string> list, List<string> fileExtsions)
{
//添加文件
string[] files = Directory.GetFiles(dir);
if (fileExtsions.Count > 0)
{
foreach (string file in files)
{
string extension = Path.GetExtension(file);
if (extension != null && fileExtsions.Contains(extension))
{
list.Add(file);
}
}
}
else
{
list.AddRange(files);
}
//如果是目录,则递归
DirectoryInfo[] directories = new DirectoryInfo(dir).GetDirectories();
foreach (DirectoryInfo item in directories)
{
GetFiles(item.FullName, list, fileExtsions);
}
}
/// <summary>
/// 创建文件夹
/// </summary>
public static void CreateFolder()
{
// Directory.CreateDirectory();//
}
/// <summary>
/// 写入文件
/// </summary>
/// <param name="filePath">文件名</param>
/// <param name="content">文件内容</param>
public static void WriteFile(string filePath, string content)
{
try
{
var fs = new FileStream(filePath, FileMode.Create);
Encoding encode = Encoding;
//获得字节数组
byte[] data = encode.GetBytes(content);
//开始写入
fs.Write(data, 0, data.Length);
//清空缓冲区、关闭流
fs.Flush();
fs.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
/// <summary>
/// 读取文件
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static string ReadFile(string filePath)
{
return ReadFile(filePath, Encoding);
}
/// <summary>
/// 读取文件
/// </summary>
/// <param name="filePath"></param>
/// <param name="encoding"></param>
/// <returns></returns>
public static string ReadFile(string filePath, Encoding encoding)
{
using (var sr = new StreamReader(filePath, encoding))
{
return sr.ReadToEnd();
}
}
/// <summary>
/// 读取文件
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static List<string> ReadFileLines(string filePath)
{
var str = new List<string>();
using (var sr = new StreamReader(filePath, Encoding))
{
String input;
while ((input = sr.ReadLine()) != null)
{
str.Add(input);
}
}
return str;
}
/// <summary>
/// 复制文件夹(及文件夹下所有子文件夹和文件)
/// </summary>
/// <param name="sourcePath">待复制的文件夹路径</param>
/// <param name="destinationPath">目标路径</param>
public static void CopyDirectory(String sourcePath, String destinationPath)
{
var info = new DirectoryInfo(sourcePath);
Directory.CreateDirectory(destinationPath);
foreach (FileSystemInfo fsi in info.GetFileSystemInfos())
{
String destName = Path.Combine(destinationPath, fsi.Name);
if (fsi is FileInfo) //如果是文件,复制文件
File.Copy(fsi.FullName, destName);
else //如果是文件夹,新建文件夹,递归
{
Directory.CreateDirectory(destName);
CopyDirectory(fsi.FullName, destName);
}
}
}
/// <summary>
/// 删除文件夹(及文件夹下所有子文件夹和文件)
/// </summary>
/// <param name="directoryPath"></param>
public static void DeleteFolder(string directoryPath)
{
foreach (string d in Directory.GetFileSystemEntries(directoryPath))
{
if (File.Exists(d))
{
var fi = new FileInfo(d);
if (fi.Attributes.ToString().IndexOf("ReadOnly", StringComparison.Ordinal) != -1)
fi.Attributes = FileAttributes.Normal;
File.Delete(d); //删除文件
}
else
DeleteFolder(d); //删除文件夹
}
Directory.Delete(directoryPath); //删除空文件夹
}
/// <summary>
/// 清空文件夹(及文件夹下所有子文件夹和文件)
/// </summary>
/// <param name="directoryPath"></param>
public static void ClearFolder(string directoryPath)
{
foreach (string d in Directory.GetFileSystemEntries(directoryPath))
{
if (File.Exists(d))
{
var fi = new FileInfo(d);
if (fi.Attributes.ToString().IndexOf("ReadOnly", StringComparison.Ordinal) != -1)
fi.Attributes = FileAttributes.Normal;
File.Delete(d); //删除文件
}
else
DeleteFolder(d); //删除文件夹
}
}
/// <summary>
/// 取得文件大小,按适当单位转换
/// </summary>
/// <param name="filepath"></param>
/// <returns></returns>
public static string GetFileSize(string filepath)
{
string result = "0KB";
if (File.Exists(filepath))
{
var size = new FileInfo(filepath).Length;
int filelength = size.ToString().Length;
if (filelength < 4)
result = size + "byte";
else if (filelength < 7)
result = Math.Round(Convert.ToDouble(size / 1024d), 2) + "KB";
else if (filelength < 10)
result = Math.Round(Convert.ToDouble(size / 1024d / 1024), 2) + "MB";
else if (filelength < 13)
result = Math.Round(Convert.ToDouble(size / 1024d / 1024 / 1024), 2) + "GB";
else
result = Math.Round(Convert.ToDouble(size / 1024d / 1024 / 1024 / 1024), 2) + "TB";
return result;
}
return result;
}
/// <summary>
/// 删除文件.
/// </summary>
/// <param name="path">删除完整文件夹路径.</param>
/// <param name="name">删除文件的名称.</param>
public static void DeleteFile(string path, string name)
{
File.Delete(path + name);
}
// /// <summary>
// /// 删除文件
// /// </summary>
// /// <param name="path"></param>
// /// <param name="filesName"></param>
// /// <returns></returns>
// public static bool DeleteFiles(string path, string filesName)
// {
// bool isDelete = false;
// try
// {
// if (Directory.Exists(path))
// {
// if (File.Exists(PathUtil.Build(path, filesName)))
// {
// File.Delete(PathUtil.Build(path, filesName));
// isDelete = true;
// }
// }
// }
// catch
// {
// return isDelete;
// }
//
// return isDelete;
// }
/// <summary>
/// 删除文件夹下所有子文件夹与文件
/// </summary>
public static void DeleteAllChild(string path, FileAttributes filter)
{
if (!Directory.Exists(path))
return;
DirectoryInfo dir = new DirectoryInfo(path);
FileInfo[] files = dir.GetFiles("*");
for (int i = 0; i < files.Length; ++i)
{
if ((files[i].Attributes & filter) > 0)
continue;
if (File.Exists(files[i].FullName))
File.Delete(files[i].FullName);
}
DirectoryInfo[] dirs = dir.GetDirectories("*");
for (int i = 0; i < dirs.Length; ++i)
{
if ((dirs[i].Attributes & filter) > 0)
continue;
if (Directory.Exists(dirs[i].FullName))
Directory.Delete(dirs[i].FullName, true);
}
}
/// <summary>
/// 绝对路径转相对路径
/// </summary>
public static string AbsoluteToRelativePath(string root_path, string absolute_path)
{
absolute_path = absolute_path.Replace('\\', '/');
int last_idx = absolute_path.LastIndexOf(root_path);
if (last_idx < 0)
return absolute_path;
int start = last_idx + root_path.Length;
if (absolute_path[start] == '/')
start += 1;
int length = absolute_path.Length - start;
return absolute_path.Substring(start, length);
}
/// <summary>
/// 获得取除路径扩展名的路径
/// </summary>
public static string GetPathWithoutExtension(this string full_name)
{
int last_idx = full_name.LastIndexOfAny(".".ToCharArray());
if (last_idx < 0)
return full_name;
return full_name.Substring(0, last_idx);
}
/// <summary>
/// 将字符串转为大写或小写
/// </summary>
/// <param name="tmp"></param>
/// <param name="isUpper"></param>
/// <returns></returns>
public static string GetUpperOrLower(this string tmp, bool isUpper = true)
{
if (isUpper)
return tmp.ToLower();
else
return tmp.ToUpper();
}
/// <summary>
/// 判断是否有中文,有转为全拼
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
// public static string ChineseToPinYin(string text, bool isfile = true)
// {
// if (HasChinese(text))
// {
// return ConvertPinYin(text, isfile).GetUpperOrLower().Replace(" ", "");
// }
// else
// {
// if (isfile)
// text = String.Concat("_", text);
// return text.GetUpperOrLower();
// }
// }
/// <summary>
/// 判断字符串中是否有中文
/// </summary>
private static bool HasChinese(string s)
{
return Regex.IsMatch(s, "[\u4e00-\u9fbb]");
}
/// <summary>
/// 汉字转全拼
/// </summary>
// private static string ConvertPinYin(string text, bool isfile = true)
// {
// if (string.IsNullOrEmpty(text))
// return text;
//
// try
// {
// var sb = new StringBuilder();
// bool isfirstchinese = false;
// if (HasChinese(text.ToList()[0].ToString()))
// {
// isfirstchinese = true;
// }
//
// for (int i = 0; i < text.ToList().Count; i++)
// {
// if (text.ToList()[i] <= 127)
// sb.Append(text.ToList()[i]);
// else
// sb.Append($"_{NPinyin.Pinyin.GetPinyin(text.ToList()[i])}_");
// }
//
// var name = sb.ToString().Replace("__", "_");
// if (!isfile) //裁剪首尾字符“_”
// {
// name = name.Trim('_');
// }
// else
// {
// name = name.TrimEnd('_');
// if (!isfirstchinese)
// name = String.Concat("_", name);
// }
//
// return name;
// }
// catch (Exception e)
// {
// Debug.LogError($"拼音转换失败:{text} {e.Message}");
// }
//
// return text;
// }
/// <summary>
/// 删除指定字符后的字符串
/// </summary>
/// <param name="fileName">字符串</param>
/// <param name="lastIndex">符号例如:“ .”</param>
/// <returns></returns>
public static string DeleteLastIndex(string fileName, string lastIndex)
{
int index = fileName.LastIndexOf(lastIndex);
if (index >= 0)
{
fileName = fileName.Substring(0, index);
}
return fileName;
}
/// <summary>
/// 带颜色的日志输出
/// </summary>
public static void LogColor(string s, string path = null, Color color = default)
{
if (string.IsNullOrEmpty(path))
Debug.Log($"<color=#{ColorUtility.ToHtmlStringRGB(color)}>{s}</color>");
else
{
string assetPath = s.Replace("\\", "/").Replace(Application.dataPath, "Assets");
Debug.Log($"<color=#{ColorUtility.ToHtmlStringRGB(color)}>{assetPath}</color>",
AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(assetPath));
}
}
/// <summary>
/// 过滤:去掉首尾空格和换行符【\n】
/// </summary>
private static string FilterTo(string self)
{
self = self.TrimStart();
self = self.TrimEnd();
self = self.Replace("\n", "");
return self;
}
/// <summary>
/// 获取Assets下带.meta文件的资源的路径
/// </summary>
/// <param name="objectName">文件夹、资源</param>
private static string[] GetPathsOfAssetsObject(string objectName)
{
string[] guids = AssetDatabase.FindAssets(objectName);
string[] paths = new string[guids.Length];
for (int i = 0; i < guids.Length; i++)
{
string path = AssetDatabase.GUIDToAssetPath(guids[i]);
if (path.Contains("Assets"))
paths[i] = path;
}
return paths;
}
}
#endif
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 46cba106b812e6244a8d564849dd290a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4f1217f9aa6674740afe51db32d6d46f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,24 @@
fileFormatVersion: 2
guid: 7dfb627e8ab8af84c92cc52d66888c25
timeCreated: 1453536009
licenseType: Pro
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 1
settings: {}
Editor:
enabled: 0
settings:
DefaultValueInitialized: true
WindowsStoreApps:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: b6f487270cfb1cb44bc5b5c70462786f
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: a0ddbcdd27271534b8277ca2bddffca7
folderAsset: yes
timeCreated: 1531104110
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 7e3f17ca90ece22438eaaf291cdf55d0
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 62dd34932f2b9034985e3802a02e3312
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 78c1f6d64a65d7746893d7863c4190da
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: e574b19de6650b9468301fdc43ed0e75
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 6be8b9ff3c2d68b4c93997d421034d15
timeCreated: 1531103978
licenseType: Pro
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: fa2a07ff605e5664a830c8247ce1f8d0
timeCreated: 1531103979
licenseType: Pro
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,24 @@
fileFormatVersion: 2
guid: 92cce7f762d252b40853ec8cfca85b7c
timeCreated: 1453461718
licenseType: Pro
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 1
settings: {}
Editor:
enabled: 0
settings:
DefaultValueInitialized: true
WindowsStoreApps:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1 +1 @@
# 代码检查工具
# 表格转化工具

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3f4958b2707b1874fb59e045842881b7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
namespace Stary.Evo.TableTextConversion
{
public interface ITableData
{
public string TableName { get; }
}
public enum TableName
{
AudioTableData,
AudioTextData
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 33bd2c65630947399d1eb3e8c3e454c1
timeCreated: 1743415380

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f458924b47972e344ab95e73c17cec83
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Stary.Evo.TableTextConversion
{
public class AudioTableData : ScriptableObject, ITableData
{
public string TableName { get; }
public List<MessageInfo> infos;
[Serializable]
public class MessageInfo
{
// 序号
[GUIColor(0, 1, 0)] public int index;
// 名称
public string name;
// 名称描述
public string nameMessage;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2123856275778e24ebda59ff88f2d153
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Stary.Evo.TableTextConversion
{
public class UITableData : ScriptableObject, ITableData
{
public string TableName { get; }
public List<MessageInfo> infos;
[Serializable]
public class MessageInfo
{
// 序号
[GUIColor(0, 1, 0)] public int index;
// 名称
public string name;
// 名称描述
public string nameMessage;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d87122eaab924cad9155ee33a31ebcc3
timeCreated: 1743496104

View File

@@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using Stary.Evo.TableTextConversion;
public class Test : MonoBehaviour
{
// Start is called before the first frame update
/*async void Start()
{
Task<AudioTableData> audioTableData = ReadDumpInformation.Read<AudioTableData>();
await audioTableData;
AudioTableData data = audioTableData.Result;
if (data != null)
{
Debug.Log($"UnityEvo:{data.infos[3].name}");
}
}*/
void Start()
{
AudioTableData audioTableData = ReadDumpInformation.ReadInEditor<AudioTableData>();
if (audioTableData != null)
{
Debug.Log($"UnityEvo:{audioTableData.infos[3].name}");
}
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5cc8857da4ee2534289add72195af962
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 102768b9489625641a18c187eac264be
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,40 @@
using System.Threading.Tasks;
using UnityEngine;
using YooAsset;
namespace Stary.Evo.TableTextConversion
{
public static class ReadDumpInformation
{
public static async Task<T> Read<T>() where T : ScriptableObject, ITableData
{
var conf = YooAssets.LoadAssetAsync($"Config_{typeof(T).Name}");
await conf.Task;
if (conf.Status == EOperationStatus.Succeed)
{
return conf.AssetObject as T;
}
else
{
Debug.LogError("UnityEvo:" + "配置文件:" + typeof(T).Name + "加载失败!!!");
return null;
}
}
#if UNITY_EDITOR
public static T ReadInEditor<T>() where T : ScriptableObject, ITableData
{
// 同步加载并直接返回结果
var conf = Resources.Load<T>(typeof(T).Name);
if (conf != null)
{
return conf;
}
Debug.LogError($"UnityEvo:配置文件同步加载失败:{typeof(T).Name}");
return null;
}
#endif
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 64089130470a47d496bd6c8168cd95f6
timeCreated: 1743415570

View File

@@ -1,10 +1,10 @@
{
"name": "com.staryevo.tabletextconversion",
"version": "1.0.0",
"name": "com.staryevo.codechecker",
"version": "1.0.1",
"displayName": "05.TableTextConversion",
"description": "配置导出工具",
"description": "表格转化工具",
"unity": "2021.3",
"unityRelease": "30f1",
"unityRelease": "23f1",
"keywords": [
"unity",
"scirpt"