unityzgy/Assets/Scripts/ZFramwork/Editor/CreatExcuteCSWindow.cs
ayuan9957 bf12e02276 feat: 多语言本地化系统 - 支持中/英/法/俄实时切换
- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg)
- LoginPanel: InputField placeholder本地化、字体颜色保持
- HistoryPanel: 用时数据本地化、placeholder本地化
- RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建)
- AppraiseWindowBase: 评价等级本地化、操作消息重建
- EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized
- StudentOperateRecorder: 新增InjectOperateMsgLocalized方法
- LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选
- 字体切换时保留颜色和verticalOverflow
2026-07-16 10:05:59 +08:00

65 lines
2.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
public class CreatExcuteCSWindow : EditorWindow
{
string inputCSPath="Scripts/"; // 文本内容
string inputCSNames = ""; // 文本内容
[MenuItem("Tools/CreatCS/NetCS/IExcute")]
public static void ShowWindow()
{
// 显示某个编辑器窗口。传参即是要显示的窗口类型(类名)
EditorWindow.GetWindow(typeof(CreatExcuteCSWindow));
}
void OnGUI()
{
//// 文本
//GUILayout.Label("Base Setting");
// 可以编辑,编辑后用同一个变量保存结果
inputCSPath = EditorGUILayout.TextField("输入脚本存储文件夹路径:", inputCSPath);
GUILayout.Label("创建多个时使用,分割例如LoginResult,TcpSub");
inputCSNames = EditorGUILayout.TextField("消息处理类名称:", inputCSNames);
// 按钮
if (GUILayout.Button("创建脚本"))
{
inputCSNames.Trim();
string[] excuteCSNames = inputCSNames.Split(',');
for (int i = 0; i < excuteCSNames.Length; i++)
{
CreatExcuteCS(excuteCSNames[i], Application.dataPath+"/"+ inputCSPath);
}
}
}
//创建一个网络消息处理类
public static void CreatExcuteCS(string msgName,string csFolde)
{
string csName = msgName + "Excute";
string filePath = $"{csFolde}/{csName}.cs";
if (!Directory.Exists(csFolde))
Directory.CreateDirectory(csFolde);//创建文件夹
if (File.Exists(filePath))
{
Debug.LogWarning("不能创建名称重复的脚本");
return;
}
StreamWriter sw = new StreamWriter(filePath);
sw.WriteLine("using XFramework.NetOuter;");
sw.WriteLine($"public class {csName} : INetExcute");
sw.WriteLine("{");
sw.WriteLine($"\tpublic override void NetExcute(ExcuteParam param) \n\t{{\n\t}}");//实现接口
sw.WriteLine("}");
sw.Flush();
sw.Close();
AssetDatabase.Refresh();
Debug.Log($"生成物体控制脚本{csFolde}/{csName}");
}
}