コード例 #1
0
    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();
    }
コード例 #2
0
    //[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();
    }