自动创建预设脚本
再日常游戏开发过程中,有些模块的文件夹,以及脚本都是固定格式的。
为了方便,可以写一个编辑器工具,根据模块名字,自动创建文件夹和所必须的脚本。
根据 demo脚本 自动创建生成脚本
// 核心逻辑,读取demo脚本,修改脚本名字
void CreateLuaFiles() {
string pathFile = demoPath + "/" + keys.Current.Value + ".lua";
string savePath = rootPath + "/" + moduleName + "/" + savePathInfo[keys.Current.Key] + ".lua";
savePath = string.Format(savePath, moduleName, otherName);
FileStream fileStream = File.OpenRead(pathFile);
byte[] bytes = new byte[fileStream.Length];
fileStream.Read(bytes, 0, (int)fileStream.Length);
fileStream.Close();
string content = System.Text.Encoding.UTF8.GetString(bytes);
content = ReplaceInfo(content); // 替换
bytes = System.Text.Encoding.UTF8.GetBytes(conte