Exemplo n.º 1
0
    /// <summary>
    /// 编译模式
    /// </summary>
    /// <param name="outpath"></param>
    /// <param name="platform"></param>
    /// <param name="mode"></param>
    static public void RoslynBuild(string outpath, RuntimePlatform platform, ScriptBuildTools.BuildMode mode, bool isShowTips = true)
    {
        //触发bd环境周期
        BDFrameEditorBehaviorHelper.OnBeginBuildDLL();

        var targetPath = "Assets/Code/BDFramework.Game/ILRuntime/Binding/Analysis";
        //1.分析之前先删除,然后生成临时文件防止报错
        // if (Directory.Exists(targetPath))
        // {
        //     Directory.Delete(targetPath, true);
        // }

        var fileContent = @"
        namespace ILRuntime.Runtime.Generated
        {
            class CLRBindings
            {

                internal static ILRuntime.Runtime.Enviorment.ValueTypeBinder<UnityEngine.Vector2> s_UnityEngine_Vector2_Binding_Binder = null;
                internal static ILRuntime.Runtime.Enviorment.ValueTypeBinder<UnityEngine.Vector3> s_UnityEngine_Vector3_Binding_Binder = null;
                internal static ILRuntime.Runtime.Enviorment.ValueTypeBinder<UnityEngine.Vector4> s_UnityEngine_Vector4_Binding_Binder = null;
                internal static ILRuntime.Runtime.Enviorment.ValueTypeBinder<UnityEngine.Quaternion> s_UnityEngine_Quaternion_Binding_Binder = null;
                public static void Initialize(ILRuntime.Runtime.Enviorment.AppDomain app)
                {
                }
            } 
        }   ";

        FileHelper.WriteAllText(targetPath + "/CLRBindings.cs", fileContent);
        AssetDatabase.Refresh(); //这里必须要刷新

        //2.生成DLL
        ScriptBuildTools.BuildDll(outpath, platform, mode, isShowTips);

        //3.预绑定
        //GenPreCLRBinding();
        //4.生成自动分析绑定
        GenCLRBindingByAnalysis(platform, outpath);
        AssetDatabase.Refresh();
        //触发bd环境周期
        BDFrameEditorBehaviorHelper.OnEndBuildDLL(outpath);
    }
    /// <summary>
    /// 编译模式
    /// </summary>
    /// <param name="outpath"></param>
    /// <param name="platform"></param>
    /// <param name="mode"></param>
    static public void RoslynBuild(string outpath, RuntimePlatform platform, ScriptBuildTools.BuildMode mode)
    {
        //触发bd环境周期
        BDFrameEditorBehaviorHelper.OnBeginBuildDLL();

        var targetPath = "Assets/Code/Game/ILRuntime/Binding/Analysis";

        //1.分析之前先删除,然后生成临时文件防止报错
        if (Directory.Exists(targetPath))
        {
            Directory.Delete(targetPath, true);
        }

        var fileContent = @"
        namespace ILRuntime.Runtime.Generated
        {
            class CLRBindings
            {
                public static void Initialize(ILRuntime.Runtime.Enviorment.AppDomain app)
                {
                }
            } 
        }   ";

        FileHelper.WriteAllText(targetPath + "/CLRBindings.cs", fileContent);
        AssetDatabase.Refresh(); //这里必须要刷新

        //2.生成DLL
        ScriptBuildTools.BuildDll(outpath, platform, mode);

        //3.预绑定
        //GenPreCLRBinding();
        //4.生成自动分析绑定
        GenCLRBindingByAnalysis(platform, outpath);
        AssetDatabase.Refresh();
        //触发bd环境周期
        BDFrameEditorBehaviorHelper.OnEndBuildDLL(outpath);
        AssetHelper.GenPackageBuildInfo(outpath, platform);
        Debug.Log("脚本打包完毕");
    }