static void ExportSimple() { // 先加载配置表 string szPath = Application.dataPath; szPath = szPath.Substring(0, szPath.Length - 6); FCRefClassCfg used_cfg = FCRefClassCfg.LoadCfg(szPath + "ref_name.xml"); FCRefClassCfg custom = FCRefClassCfg.LoadCfg(szPath + "custom_name.xml"); if (used_cfg != null) { used_cfg.MergeFinder(custom); } FCClassWrap pWrap = new FCClassWrap(); pWrap.BeginExport(""); pWrap.SetRefClassCfg(used_cfg); WrapUnityClass(pWrap); pWrap.SetRefClassCfg(used_cfg); WrapUIClass(pWrap); pWrap.SetRefClassCfg(null); WrapCustomAttribClass(pWrap); // 导出打有[ClassAutoWrap]标签的类 pWrap.EndExport(); }
public static void SaveCfg(FCRefClassCfg cfg, string szPathName) { UTF8Encoding utf8 = new UTF8Encoding(false); StreamWriter stream = new StreamWriter(szPathName, false, utf8); System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(FCRefClassCfg)); xs.Serialize(stream, cfg); stream.Close(); }
public void MergeFinder(FCRefClassCfg other) { // 合并 m_Finder = null; MakerFinder(RefClass); if (other == null) { return; } MakerFinder(other.RefClass); }
//[MenuItem("FCScript/测试", false, 5)] static void TestXml() { Assembly assembly = Assembly.Load("UnityEngine.UI"); Type t1 = assembly.GetType("Button"); Type t2 = assembly.GetType("UnityEngine.UI.Button"); Type t3 = assembly.GetType("UnityEngine.Button"); string szPath = Application.dataPath; szPath = szPath.Substring(0, szPath.Length - 6); FCRefClassCfg ins = FCRefClassCfg.LoadCfg(szPath + "ref_name.xml"); string szCfgPathName = szPath + "test_name.xml"; if (File.Exists(szCfgPathName)) { File.Delete(szCfgPathName); } //FileStream stream = new FileStream(szCfgPathName, FileMode.Create, FileAccess.Write); UTF8Encoding utf8 = new UTF8Encoding(false); StreamWriter stream = new StreamWriter(szCfgPathName, false, utf8); System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(FCRefClassCfg)); FCRefClassCfg cfg = new FCRefClassCfg(); cfg.RefClass = new List <FCRefClass>(); FCRefClass node = new FCRefClass(); node.ClassName = "GameObject"; node.names.Add("Find"); node.names.Add("tag"); cfg.RefClass.Add(node); node = new FCRefClass(); node.ClassName = "Button"; node.names.Add("Enable"); node.names.Add("Active"); node.TemplateParams = new List <FCTemplateParams>(); FCTemplateParams sParam = new FCTemplateParams(); sParam.FuncName = "AddCompent"; sParam.names.Add("Button"); sParam.names.Add("Text"); sParam.names.Add("Sprite"); node.TemplateParams.Add(sParam); cfg.RefClass.Add(node); xs.Serialize(stream, cfg); stream.Close(); }
public static FCRefClassCfg LoadCfg(string szPathName) { FCRefClassCfg cfg = null; try { if (!File.Exists(szPathName)) { Debug.Log(szPathName + "不存在,请先编译或手动配置。"); return(null); } StreamReader stream = new StreamReader(szPathName, Encoding.UTF8); XmlSerializer xs = new XmlSerializer(typeof(FCRefClassCfg)); cfg = xs.Deserialize(stream) as FCRefClassCfg; } catch (Exception e) { Debug.LogException(e); } return(cfg); }