public static void CreateWindowCS(string goName, string prefabName) { MyClass mc = new MyClass("Window_" + goName + ": AWindow "); mc.AddAttribute(string.Format("UI(0,\"{0}\")", "Windows/" + prefabName)); mc.AddNameSpace(new string[3] { "BDFramework.UI", "UnityEngine", "BDFramework.UI" }); MyMethod construct = new MyMethod(); construct.OverwriteContent(@"//[Note] public [method name](string path) : base(path) { }"); construct.SetMethSign(null, "Window_" + goName, null); mc.AddMethod(construct); MyMethod init = new MyMethod(); init.OverwriteContent(overrideContent); init.SetMethSign(null, "Init", null); init.SetMethodContent("base.Init();"); mc.AddMethod(init); MyMethod close = new MyMethod(); close.OverwriteContent(overrideContent); close.SetMethSign(null, "Close", null); close.SetMethodContent("base.Close();"); mc.AddMethod(close); MyMethod open = new MyMethod(); open.OverwriteContent(overrideContent); open.SetMethSign(null, "Open", null); open.SetMethodContent("base.Open();"); mc.AddMethod(open); MyMethod destroy = new MyMethod(); destroy.OverwriteContent(overrideContent); destroy.SetMethSign(null, "Destroy", null); destroy.SetMethodContent("base.Destroy();"); mc.AddMethod(destroy); string path = Application.dataPath + windowPath; if (!Directory.Exists(path)) { Debug.LogError(string.Format("文件夹不存在!路径:{0}", path)); return; } path = path + "Window_" + goName + ".cs"; File.WriteAllText(path, mc.ToString()); Debug.Log(string.Format("生成成功!路径:{0}", path)); }