static void AddTemplateSurport(FCClassWrap pWrap)
    {
        List <Type> aSupportType = FCExclude.SupportTemplateTypes;

        pWrap.PushTemplateFuncWrapSupport("AddComponent", aSupportType);
        pWrap.PushTemplateFuncWrapSupport("GetComponent", aSupportType);
    }
Beispiel #2
0
    static void WrapUnityClass(FCClassWrap pWrap)
    {
        pWrap.BeginModleWrap("Unity");

        //pWrap.WrapClass(typeof(System.Type));
        pWrap.WrapClass(typeof(UnityEngine.Time));
        pWrap.WrapClass(typeof(UnityEngine.Object));
        AddTemplateSurport(pWrap); // 添加模板函数的wrap支持
        pWrap.WrapClass(typeof(UnityEngine.Component));
        pWrap.WrapClass(typeof(UnityEngine.Transform));
        pWrap.PushCurrentDontWrapName("alphaIsTransparency");
        pWrap.WrapClass(typeof(UnityEngine.Texture2D));
        AddTemplateSurport(pWrap); // 添加模板函数的wrap支持
        pWrap.WrapClass(typeof(UnityEngine.GameObject));
        pWrap.WrapClass(typeof(UnityEngine.Behaviour));
        pWrap.PushCurrentDontWrapName("Item");
        pWrap.WrapClass(typeof(UnityEngine.Animation));
        pWrap.WrapClass(typeof(UnityEngine.Transform));
        pWrap.WrapClass(typeof(UnityEngine.Renderer));
        pWrap.WrapClass(typeof(UnityEngine.MeshRenderer));
        pWrap.WrapClass(typeof(UnityEngine.SkinnedMeshRenderer));
        pWrap.PushCurrentDontWrapName("IsJoystickPreconfigured");
        pWrap.WrapClass(typeof(UnityEngine.Input));
        pWrap.PushCurrentDontWrapName("areaSize");
        pWrap.PushCurrentDontWrapName("lightmapBakeType");
        pWrap.WrapClass(typeof(UnityEngine.Light));
        pWrap.WrapClass(typeof(UnityEngine.Material));
        pWrap.WrapClass(typeof(UnityEngine.Events.UnityEvent));

        pWrap.EndModleWrap();
    }
Beispiel #3
0
    static void WrapUnityClass(FCClassWrap pWrap)
    {
        pWrap.BeginModleWrap("Unity");

        WrapType(pWrap, typeof(UnityEngine.Time));
        WrapType(pWrap, typeof(UnityEngine.Object));
        WrapType(pWrap, typeof(UnityEngine.Component));
        WrapType(pWrap, typeof(UnityEngine.Transform));
        WrapType(pWrap, typeof(UnityEngine.Texture2D));
        WrapType(pWrap, typeof(UnityEngine.GameObject));
        WrapType(pWrap, typeof(UnityEngine.Behaviour));
        WrapType(pWrap, typeof(UnityEngine.MonoBehaviour));
        WrapType(pWrap, typeof(UnityEngine.Animation));
        WrapType(pWrap, typeof(UnityEngine.Renderer));
        WrapType(pWrap, typeof(UnityEngine.MeshRenderer));
        WrapType(pWrap, typeof(UnityEngine.SkinnedMeshRenderer));
        WrapType(pWrap, typeof(UnityEngine.Input));
        WrapType(pWrap, typeof(UnityEngine.Light));
        WrapType(pWrap, typeof(UnityEngine.Material));
        WrapType(pWrap, typeof(UnityEngine.Events.UnityEvent));
        WrapType(pWrap, typeof(UnityEngine.AsyncOperation));
        WrapType(pWrap, typeof(UnityEngine.SceneManagement.Scene));
        WrapType(pWrap, typeof(UnityEngine.SceneManagement.SceneManager));

        pWrap.EndModleWrap();
    }
Beispiel #4
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();
    }
Beispiel #5
0
    static void WrapCustomClass(FCClassWrap pWrap)
    {
        pWrap.BeginModleWrap("Custom");

        pWrap.WrapClass(typeof(TestExport)); // 导出一个测试的类

        pWrap.EndModleWrap();
    }
Beispiel #6
0
    static void ClearWrapFile()
    {
        string szDataPath     = Application.dataPath;
        string szExportPath   = szDataPath + "/FCWrap/";
        string szFCScriptPath = szDataPath.Substring(0, szDataPath.Length - 6) + "Script/inport/";

        FCClassWrap.DeletePath(szExportPath);
        FCClassWrap.DeletePath(szFCScriptPath);
    }
Beispiel #7
0
    static void WrapUIClass(FCClassWrap pWrap)
    {
        pWrap.BeginModleWrap("UnityUI");
        // 导出UI类
        WrapType(pWrap, typeof(UnityEngine.UI.Button));
        WrapType(pWrap, typeof(UnityEngine.UI.Text));

        pWrap.EndModleWrap();
    }
Beispiel #8
0
    static void WrapUIClass(FCClassWrap pWrap)
    {
        pWrap.BeginModleWrap("UnityUI");
        // 导出UI类
        pWrap.WrapClass(typeof(UnityEngine.UI.Button));
        pWrap.PushCurrentDontWrapName("OnRebuildRequested");
        pWrap.WrapClass(typeof(UnityEngine.UI.Text));

        pWrap.EndModleWrap();
    }
Beispiel #9
0
    static void ExportAll()
    {
        FCClassWrap pWrap = new FCClassWrap();

        pWrap.BeginExport("");

        WrapUnityClass(pWrap);
        WrapUIClass(pWrap);
        WrapCustomAttribClass(pWrap); // 导出打有[ClassAutoWrap]标签的类

        pWrap.EndExport();
    }
Beispiel #10
0
    static void AddTemplateSurport(FCClassWrap pWrap)
    {
        List <Type> aSupportType = new List <Type>();

        aSupportType.Add(typeof(UnityEngine.SkinnedMeshRenderer));
        aSupportType.Add(typeof(UnityEngine.MeshRenderer));
        aSupportType.Add(typeof(UnityEngine.Animation));
        aSupportType.Add(typeof(UnityEngine.Light));

        aSupportType.Add(typeof(UnityEngine.UI.Button));
        aSupportType.Add(typeof(UnityEngine.UI.Text));
        // 在这里添加其他的类的吧

        pWrap.PushTemplateFuncWrapSupport("AddComponent", aSupportType);
        pWrap.PushTemplateFuncWrapSupport("GetComponent", aSupportType);
    }
    static void ExportAll()
    {
        FCClassWrap pWrap = new FCClassWrap();

        pWrap.BeginExport("");

        Dictionary <string, List <Type> > allExportTypes = FCExclude.GetAllExportType();

        foreach (var v in allExportTypes)
        {
            WrapAllClass(pWrap, v.Key, v.Value);
        }
        WrapCustomAttribClass(pWrap); // 导出打有[ClassAutoWrap]标签的类
        pWrap.EndExport();
        MakeFCProj();
    }
Beispiel #12
0
    public void ExportFC(string szPath, bool bExportReadWriteFunc)
    {
        // 先删除该目录下的文件
        FCClassWrap.DeletePath(szPath);
        System.IO.Directory.CreateDirectory(szPath);

        StringBuilder szFileData = new StringBuilder(1024 * 1024 * 4);
        PBMessageFile pMsgFile = null;
        PBMessage     pMsg = null;
        string        szPathName = string.Empty, szFileName = string.Empty;
        int           nFileCount  = m_MessageFiles.Count;
        int           nClassCount = 0;

        // 先导出PBTpye, 已经内置了,不需要导出了
        //szFileData.Append("enum PB_ZipType\r\n");
        //szFileData.Append("{\r\n");
        //szFileData.Append("    PB_Zip_Varint = 0,\r\n");
        //szFileData.Append("    PB_Zip_Fixed  = 1,\r\n");
        //szFileData.Append("    PB_Zip_ZigZag = 2,\r\n");
        //szFileData.Append("};\r\n");
        //szPathName = szPath + "FCProtobufType.cs";
        //System.IO.File.WriteAllText(szPathName, szFileData.ToString());

        for (int i = 0; i < nFileCount; ++i)
        {
            pMsgFile = m_MessageFiles[i];
            szFileData.Clear();
            for (int j = 0; j < pMsgFile.m_Enums.Count; ++j)
            {
                pMsgFile.m_Enums[j].ExportFC(ref szFileData, 0);
            }
            nClassCount = pMsgFile.m_Messages.Count;
            for (int j = 0; j < nClassCount; ++j)
            {
                pMsg = pMsgFile.m_Messages[j];
                pMsg.ExportFCScript(ref szFileData, 0, bExportReadWriteFunc);
            }
            szFileName  = pMsgFile.m_szFileName;
            szFileName += ".cs";
            szPathName  = szPath;
            szPathName += szFileName;

            // 保存
            //System.IO.File.WriteAllText(szPathName, szFileData.ToString());
            SaveUTF8File(szPathName, szFileData.ToString());
        }
    }
    static void TestExport()
    {
        Type        t1   = typeof(IEnumerable <AssetBundle>);
        FCValueType v1   = FCValueType.TransType(t1);
        string      s1   = v1.GetValueName(true);
        int         iiii = 0;

        FCClassWrap pWrap = new FCClassWrap();

        pWrap.BeginExport("");

        pWrap.BeginModleWrap("AutoClass");
        pWrap.WrapClass(typeof(UnityEngine.AssetBundle));
        pWrap.EndModleWrap();

        pWrap.EndExport();
        MakeFCProj();
    }
Beispiel #14
0
    static void WrapUnityClass(FCClassWrap pWrap)
    {
        pWrap.BeginModleWrap("Unity");

        //pWrap.WrapClass(typeof(System.Type));
        pWrap.WrapClass(typeof(UnityEngine.Object));
        pWrap.WrapClass(typeof(UnityEngine.Transform));
        pWrap.WrapClass(typeof(UnityEngine.Component));
        pWrap.WrapClass(typeof(UnityEngine.Texture2D));
        pWrap.WrapClass(typeof(UnityEngine.GameObject));
        pWrap.WrapClass(typeof(UnityEngine.Behaviour));
        pWrap.PushCurrentDontWrapName("Item");
        pWrap.WrapClass(typeof(UnityEngine.Animation));
        pWrap.WrapClass(typeof(UnityEngine.Transform));
        pWrap.WrapClass(typeof(UnityEngine.SkinnedMeshRenderer));
        pWrap.WrapClass(typeof(UnityEngine.Input));

        pWrap.EndModleWrap();
    }
Beispiel #15
0
    // 功能:导出带有标签的类
    static void WrapCustomAttribClass(FCClassWrap pWrap)
    {
        pWrap.BeginModleWrap("AutoClass");

        Assembly assembly = Assembly.Load("Assembly-CSharp");

        Type[] types = assembly.GetExportedTypes();
        foreach (Type t in types)
        {
            if (t.IsDefined(typeof(AutoWrapAttribute), false))
            {
                pWrap.WrapClass(t, false);
            }
            else if (t.IsDefined(typeof(PartWrapAttribute), false))
            {
                pWrap.WrapClass(t, true);
            }
        }
        pWrap.EndModleWrap();
    }
    static void PrepareWrap(FCClassWrap pWrap, Type nClassType)
    {
        // 添加黑名单函数
        List <string> rList = FCExclude.GetClassBlackList(nClassType);

        if (rList != null)
        {
            foreach (string funcName in rList)
            {
                pWrap.PushCurrentDontWrapName(funcName);
            }
        }
        // 目前只有两个类型支持模板函数,其他的需要用户自己扩展
        if (nClassType == typeof(UnityEngine.Component) ||
            nClassType == typeof(UnityEngine.GameObject))
        {
            List <Type> aSupportType = FCExclude.SupportTemplateTypes;
            pWrap.PushTemplateFuncWrapSupport("AddComponent", aSupportType);
            pWrap.PushTemplateFuncWrapSupport("GetComponent", aSupportType);
        }
    }
    // 功能:导出这个模块下的所有类
    static void WrapAllClass(FCClassWrap pWrap, string szNamespace, List <Type> rList)
    {
        string szModleName = szNamespace.Replace('.', '_');

        pWrap.BeginModleWrap(szModleName);
        int nIndex = 0;

        foreach (Type t in rList)
        {
            ++nIndex;
            try
            {
                PrepareWrap(pWrap, t);
                pWrap.WrapClass(t);
            }
            catch (Exception e)
            {
                Debug.LogError("导出异常, nIndex = " + nIndex);
                Debug.LogException(e);
            }
        }
        pWrap.EndModleWrap();
    }
Beispiel #18
0
 static void WrapType(FCClassWrap pWrap, Type nType)
 {
     PrepareWrap(pWrap, nType);
     pWrap.WrapClass(nType);
 }