/// <summary>
        /// 异步拷贝,加载
        /// </summary>
        /// <returns></returns>
        static private IEnumerator IE_LoadSqlite()
        {
            //这里情况比较复杂,Mobile上基本认为Persistent才支持File操作,
            //可寻址目录也只有 StreamingAsset
            firstPath = IPath.Combine(Application.persistentDataPath, BDUtils.GetPlatformPath(Application.platform) + "/Local.db");
            var secPath = IPath.Combine(Application.streamingAssetsPath, BDUtils.GetPlatformPath(Application.platform) + "/Local.db");

            if (Application.isEditor)
            {
                secPath = "file://" + secPath;
            }

            WWW www = new WWW(secPath);

            yield return(www);

            if (www.isDone && www.error == null)
            {
                FileHelper.WriteAllBytes(firstPath, www.bytes);
                BDebug.Log("拷贝DB成功:" + firstPath, "red");
                Connection = new SQLiteConnection(firstPath, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create);
            }
            else
            {
                BDebug.LogError(www.error + "\n 拷贝DB失败:" + secPath);
            }
        }
    /// <summary>
    /// 编译模式
    /// </summary>
    /// <param name="mode"></param>
    static void RoslynBuild(ScriptBuildTools.BuildMode mode)
    {
        //1.build dll
        var outpath_win = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(Application.platform);

        ScriptBuildTools.BuildDll(Application.dataPath, outpath_win, mode);
        //2.同步到其他两个目录
        var outpath_android = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(RuntimePlatform.Android) + "/hotfix/hotfix.dll";
        var outpath_ios     = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(RuntimePlatform.IPhonePlayer) + "/hotfix/hotfix.dll";

        var source = outpath_win + "/hotfix/hotfix.dll";
        var bytes  = File.ReadAllBytes(source);

        if (source != outpath_android)
        {
            FileHelper.WriteAllBytes(outpath_android, bytes);
        }
        if (source != outpath_ios)
        {
            FileHelper.WriteAllBytes(outpath_ios, bytes);
        }

        //3.生成CLRBinding
        GenCLRBindingByAnalysis();
        AssetDatabase.Refresh();
        Debug.Log("脚本打包完毕");
    }
예제 #3
0
        /// <summary>
        /// 生成所有资源
        /// </summary>
        /// <param name="exportPath"></param>
        /// <param name="platform"></param>
        /// <param name="target"></param>
        static public void GenAllAssets(string exportPath, RuntimePlatform platform, BuildTarget target)
        {
            var outPath = exportPath + "/" + BDUtils.GetPlatformPath(platform);

            if (Directory.Exists(outPath))
            {
                Directory.Delete(outPath, true);
            }
            //1.打包资源
            try
            {
                AssetBundleEditorTools.GenAssetBundle("Resource/Runtime/", outPath, target);
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                return;
            }

            //2.编译脚本
            try
            {
                ScriptBuildTools.BuildDll(Application.dataPath, outPath, ScriptBuildTools.BuildMode.Release);
                var targetPath = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(platform) + "/hotfix/hotfix.dll";
                var hotFix     = outPath + "/hotfix/hotfix.dll";
                //防空
                if (!Directory.Exists(Path.GetDirectoryName(targetPath)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(targetPath));
                }

                //拷贝
                if (hotFix != targetPath)
                {
                    if (File.Exists(targetPath))
                    {
                        File.Delete(targetPath);
                    }
                    File.Copy(hotFix, targetPath, true);
                }
                //分析
                EditorWindow_ScriptBuildDll.GenCLRBindingByAnalysis(platform);
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                return;
            }

            //3.打包表格
            try
            {
                Excel2SQLiteTools.GenSQLite(outPath);
                Excel2SQLiteTools.CopyCurrentSqlToOther(outPath);
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
            }
        }
예제 #4
0
        /// <summary>
        /// 拷贝当前到其他目录
        /// </summary>
        /// <param name="outPath"></param>
        public static void CopyCurrentSqlToOther(string outPath)
        {
            //拷贝当前到其他目录
            var outpath_win = Application.streamingAssetsPath + "/" +
                              BDUtils.GetPlatformPath(RuntimePlatform.Android) + "/Local.db";
            var outpath_android = Application.streamingAssetsPath + "/" +
                                  BDUtils.GetPlatformPath(RuntimePlatform.Android) + "/Local.db";
            var outpath_ios = Application.streamingAssetsPath + "/" +
                              BDUtils.GetPlatformPath(RuntimePlatform.IPhonePlayer) + "/Local.db";
            //
            var source = outPath + "/Local.db";
            var bytes  = File.ReadAllBytes(source);

            if (source != outpath_android)
            {
                FileHelper.WriteAllBytes(outpath_android, bytes);
            }
            if (source != outpath_ios)
            {
                FileHelper.WriteAllBytes(outpath_ios, bytes);
            }
            if (source != outpath_win)
            {
                FileHelper.WriteAllBytes(outpath_win, bytes);
            }
            //刷新
            AssetDatabase.Refresh();
        }
        public static void ExecuteGenSqlite()
        {
            var outpath_win =
                IPath.Combine(Application.streamingAssetsPath, BDUtils.GetPlatformPath(Application.platform));

            Excel2SQLiteTools.GenSQLite(outpath_win);

            var outpath_android = Application.streamingAssetsPath + "/" +
                                  BDUtils.GetPlatformPath(RuntimePlatform.Android) + "/Local.db";
            var outpath_ios = Application.streamingAssetsPath + "/" +
                              BDUtils.GetPlatformPath(RuntimePlatform.IPhonePlayer) + "/Local.db";
            var source = outpath_win + "/Local.db";

            var bytes = File.ReadAllBytes(source);

            if (source != outpath_android)
            {
                FileHelper.WriteAllBytes(outpath_android, bytes);
            }
            if (source != outpath_ios)
            {
                FileHelper.WriteAllBytes(outpath_ios, bytes);
            }

            AssetDatabase.Refresh();
        }
예제 #6
0
        /// <summary>
        /// 异步拷贝,加载
        /// </summary>
        /// <returns></returns>
        static private IEnumerator IE_LoadSqlite()
        {
            //从StreamingAsset拷贝到Persistent
            //此时persistent为 firstPath
            //StreamingAsset 为 SecPath
            firstPath = IPath.Combine(Application.persistentDataPath, BDUtils.GetPlatformPath(Application.platform) + "/Local.db");
            var secPath = IPath.Combine(Application.streamingAssetsPath, BDUtils.GetPlatformPath(Application.platform) + "/Local.db");

            if (Application.isEditor)
            {
                secPath = "file://" + secPath;
            }
            WWW www = new WWW(secPath);

            yield return(www);

            if (www.isDone && www.error == null)
            {
                FileHelper.WriteAllBytes(firstPath, www.bytes);
                BDebug.Log("DB加载路径:" + firstPath, "red");
                Connection = new SQLiteConnection(firstPath, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create);
            }
            else
            {
                BDebug.LogError("加载失败DB:" + www.error);
            }
        }
예제 #7
0
    /// <summary>
    /// 分析dll生成
    /// </summary>
    /// <param name="platform"></param>
    /// <param name="dllpath"></param>
    static private void GenCLRBindingByAnalysis(RuntimePlatform platform = RuntimePlatform.Lumin, string dllpath = "")
    {
        if (platform == RuntimePlatform.Lumin)
        {
            platform = Application.platform;
        }

        //默认读StreammingAssets下面path
        if (dllpath == "")
        {
            dllpath = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(platform) + DLLPATH;
        }

        //不参与自动绑定的
        List <Type> excludeTypes = new List <Type>(); //

        excludeTypes.AddRange(manualBindingTypes);
        excludeTypes.AddRange(preBindingTypes);

        //用新的分析热更dll调用引用来生成绑定代码
        var targetPath = "Assets/Code/Game/ILRuntime/Binding/Analysis";

        ILRuntimeHelper.LoadHotfix(dllpath, false);
        BindingCodeGenerator.GenerateAnalysisBindingCode(ILRuntimeHelper.AppDomain, targetPath,
                                                         blackTypes: excludeTypes);

        ILRuntimeHelper.Close();
        AssetDatabase.Refresh();
        //暂时先不处理
    }
예제 #8
0
        /// <summary>
        /// 更新服务器配置
        /// </summary>
        /// <param name="callback"></param>
        /// <returns></returns>
        private IEnumerator UpdateServerConfig(Action callback)
        {
            var url = string.Format("{0}/{1}/{2}", FileServerUrl, BDUtils.GetPlatformPath(Application.platform), "GameConfig.json");

            Debug.Log(url);
            UnityWebRequest uwq     = UnityWebRequest.Get(url);
            GameConfig      gconfig = null;

            yield return(uwq.SendWebRequest());

            if (uwq.isDone && uwq.error == null)
            {
                var text = uwq.downloadHandler.text;
                if (!string.IsNullOrEmpty(text))
                {
                    gconfig = JsonMapper.ToObject <GameConfig>(text);
                    BDebug.Log("使用服务器配置:\n" + text);
                }
            }
            else
            {
                BDebug.LogError("Game配置无法更新,使用本地");
            }

            SetNewConfig(gconfig);
            callback?.Invoke();
        }
예제 #9
0
        public static void ExecuteGenTable()
        {
            var outpath_win =
                IPath.Combine(Application.streamingAssetsPath, BDUtils.GetPlatformPath(Application.platform));

            Excel2SQLiteTools.GenSQLite(outpath_win);

            var outpath_android = Application.streamingAssetsPath + "/" +
                                  BDUtils.GetPlatformPath(RuntimePlatform.Android) + "/Local.db";
            var outpath_ios = Application.streamingAssetsPath + "/" +
                              BDUtils.GetPlatformPath(RuntimePlatform.IPhonePlayer) + "/Local.db";
            var source = outpath_win + "/Local.db";

            if (source != outpath_android)
            {
                File.Copy(source, outpath_android, true);
            }
            if (source != outpath_ios)
            {
                File.Copy(source, outpath_ios, true);
            }

            AssetDatabase.Refresh();
            Debug.Log("脚本打包完毕");


            Debug.Log("表格导出完毕");
        }
예제 #10
0
    //生成clr绑定
    static public void GenCLRBindingByAnalysis(RuntimePlatform platform = RuntimePlatform.Lumin, string dllpath = "")
    {
        if (platform == RuntimePlatform.Lumin)
        {
            platform = Application.platform;
        }
        //默认读StreammingAssets下面path
        if (dllpath == "")
        {
            dllpath = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(platform) + "/hotfix/hotfix.dll";
        }

        //不参与自动绑定的
        List <Type> notGenerateTypes = new List <Type>()
        {
            typeof(MethodBase), typeof(MemberInfo), typeof(FieldInfo), typeof(MethodInfo), typeof(PropertyInfo)
            , typeof(Component), typeof(Type)
        };


        //用新的分析热更dll调用引用来生成绑定代码

        ILRuntimeHelper.LoadHotfix(dllpath, false);

        BindingCodeGenerator.GenerateBindingCode(ILRuntimeHelper.AppDomain, "Assets/Code/Game/ILRuntime/Binding/Analysis", notGenTypes: notGenerateTypes);

        ILRuntimeHelper.Close();
        AssetDatabase.Refresh();

        //暂时先不处理
    }
예제 #11
0
    private void Onclick_DownLoadAndLaunch()
    {
        //删除本地的文件
        var cachedir = IPath.Combine(Application.persistentDataPath, BDUtils.GetPlatformPath(Application.platform));

        if (Directory.Exists(cachedir))
        {
            Directory.Delete(cachedir, true);
        }

        var url = "http://" + this.inputField.text;

        VersionContorller.Start(UpdateMode.Repair, url, Application.persistentDataPath, (i, j) =>
        {
            this.text_DownloadProcess.text = string.Format("{0}/{1}", i, j);
            //下载完毕
            if (i == j)
            {
                this.text_DownloadProcess.text = "下载完毕";
                //启动
                GameObject.Find("BDFrame").GetComponent <BDLauncher>().Launch();
            }
        }, (e) =>
        {
            this.text_DownloadProcess.text = e;
        });
    }
예제 #12
0
        public static void ExecuteGenTable()
        {
            var outpath_win = IPath.Combine(Application.streamingAssetsPath, BDUtils.GetPlatformPath(Application.platform));

            Excel2SQLiteTools.GenSQLite(outpath_win);

            Debug.Log("表格导出完毕");
        }
예제 #13
0
        public static void ExecuteGenSqlite()
        {
            var outpath =
                IPath.Combine(Application.streamingAssetsPath, BDUtils.GetPlatformPath(Application.platform));

            //生成sql
            GenSQLite(outpath);
            CopyCurrentSqlToOther(outpath);
        }
예제 #14
0
    public void OnGUI()
    {
        GUILayout.BeginVertical();
        {
            GUILayout.Label("1.脚本打包", EditorGUIHelper.TitleStyle);
            GUILayout.Space(5);
            //第二排
            GUILayout.BeginHorizontal();
            {
                //
                if (GUILayout.Button("1.编译dll (.net版)", GUILayout.Width(200), GUILayout.Height(30)))
                {
                    ScriptBuildTools.BuildDll(Application.dataPath, Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(Application.platform), ScriptBuildTools.BuildMode.DotNet);
                    AssetDatabase.Refresh();
                }

                if (GUILayout.Button("[mono版]", GUILayout.Width(100), GUILayout.Height(30)))
                {
                    //1.build dll
                    var outpath_win = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(Application.platform);
                    ScriptBuildTools.BuildDll(Application.dataPath, outpath_win);
                    //3.生成CLRBinding
                    GenCLRBindingByAnalysis();
                    AssetDatabase.Refresh();
                    Debug.Log("脚本打包完毕");
                }
            }
            GUILayout.EndHorizontal();

            if (GUILayout.Button("2.生成CLRBinding · one for all[已集成]", GUILayout.Width(305), GUILayout.Height(30)))
            {
                GenCLRBindingByAnalysis();
            }

            if (GUILayout.Button("3.生成跨域Adapter[没事别瞎点]", GUILayout.Width(305), GUILayout.Height(30)))
            {
                GenCrossBindAdapter();
            }

            if (GUILayout.Button("4.生成Link.xml", GUILayout.Width(305), GUILayout.Height(30)))
            {
                StripCode.GenLinkXml();
            }

            GUI.color = Color.green;
            GUILayout.Label(
                @"注意事项:
     1.编译服务使用codedom,请放心使用
     2.如编译出现报错,请仔细看报错信息,和报错的代码行列,
       一般均为语法错
     3.语法报错原因可能有:主工程访问hotfix中的类, 使用宏
       编译时代码结构发生变化..等等,需要细心的你去发现"
                );
            GUI.color = GUI.backgroundColor;
        }
        GUILayout.EndVertical();
    }
예제 #15
0
        /// <summary>
        /// 加载
        /// </summary>
        /// <param name="source"></param>
        /// <param name="copyto"></param>
        /// <returns></returns>
        static IEnumerator IE_LoadScript(string root, HotfixCodeRunMode mode)
        {
            string dllPath = "";

            if (Application.isEditor)
            {
                dllPath = root + "/" + BDUtils.GetPlatformPath(Application.platform) + "/hotfix/hotfix.dll";
            }
            else
            {
                //这里情况比较复杂,Mobile上基本认为Persistent才支持File操作,
                //可寻址目录也只有 StreamingAsset
                var firstPath = Application.persistentDataPath + "/" + BDUtils.GetPlatformPath(Application.platform) +
                                "/hotfix/hotfix.dll";
                var secondPath = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(Application.platform) +
                                 "/hotfix/hotfix.dll";
                if (!File.Exists(firstPath))
                {
                    var www = new WWW(secondPath);
                    yield return(www);

                    if (www.isDone && www.error == null)
                    {
                        FileHelper.WriteAllBytes(firstPath, www.bytes);
                    }
                }
                dllPath = firstPath;
            }

            //反射执行
            if (mode == HotfixCodeRunMode.ByReflection)
            {
                var bytes = File.ReadAllBytes(dllPath);
                var mdb   = dllPath + ".mdb";
                if (File.Exists(mdb))
                {
                    var bytes2 = File.ReadAllBytes(mdb);
                    Assembly = Assembly.Load(bytes, bytes2);
                }
                else
                {
                    Assembly = Assembly.Load(bytes);
                }
                var type   = Assembly.GetType("BDLauncherBridge");
                var method = type.GetMethod("Start", BindingFlags.Public | BindingFlags.Static);
                method.Invoke(null, new object[] { false, true });
            }
            //解释执行
            else if (mode == HotfixCodeRunMode.ByILRuntime)
            {
                //解释执行模式
                ILRuntimeHelper.LoadHotfix(dllPath);
                ILRuntimeHelper.AppDomain.Invoke("BDLauncherBridge", "Start", null, new object[] { true, false });
            }
        }
    //生成clr绑定
    static public void GenCLRBindingByAnalysis(RuntimePlatform platform = RuntimePlatform.Lumin)
    {
        if (platform == RuntimePlatform.Lumin)
        {
            platform = Application.platform;
        }

        //用新的分析热更dll调用引用来生成绑定代码
        var dllpath = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(platform) + "/hotfix/hotfix.dll";

        ILRuntimeHelper.LoadHotfix(dllpath, false);
        BindingCodeGenerator.GenerateBindingCode(ILRuntimeHelper.AppDomain,
                                                 "Assets/Code/Game/ILRuntime/Binding/Analysis");
        AssetDatabase.Refresh();
        return;

        //暂时先不处理
        var assemblies = new List <Assembly>()
        {
            typeof(UnityEngine.UI.Button).Assembly,
        };
        var types = new List <Type>();

        types.Add(typeof(Vector4));
        //
//        foreach (var assm in assemblies)
//        {
//            var _ts = assm.GetTypes();
//            foreach (var t in _ts)
//            {
//                if (t.Namespace != null)
//                {
//                    if (t.FullName.Contains("UnityEngine.Android")
//                        || t.FullName.Contains("UnityEngine.iPhone")
//                        || t.FullName.Contains("UnityEngine.WSA")
//                        || t.FullName.Contains("UnityEngine.iOS")
//                        || t.FullName.Contains("UnityEngine.Windows")
//                        || t.FullName.Contains("JetBrains")
//                        || t.FullName.Contains("Editor"))
//                    {
//                        continue;
//                    }
//                }
//
//
//                types.Add(t);
//            }
//        }
//
//        types = types.Distinct().ToList();
        //PreBinding
        BindingCodeGenerator.GenerateBindingCode(types, "Assets/Code/Game/ILRuntime/Binding/PreBinding");
        AssetDatabase.Refresh();
    }
예제 #17
0
    /// <summary>
    /// 编译模式
    /// </summary>
    /// <param name="mode"></param>
    static public void RoslynBuild(ScriptBuildTools.BuildMode mode, string outpath = null)
    {
        var targetPath = "Assets/Code/Game/ILRuntime/Binding/Analysis";

        //分析之前先删除,然后生成临时文件防止报错
        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(); //这里必须要刷新

        //没指定,走默认模式
        if (string.IsNullOrEmpty(outpath))
        {
            //1.build dll
            var outpath_win = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(Application.platform);
            ScriptBuildTools.BuildDll(outpath_win, mode);
            //2.同步到其他两个目录
            var outpath_android = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(RuntimePlatform.Android) + DLLPATH;
            var outpath_ios     = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(RuntimePlatform.IPhonePlayer) + DLLPATH;

            var source = outpath_win + DLLPATH;
            var bytes  = File.ReadAllBytes(source);
            if (source != outpath_android)
            {
                FileHelper.WriteAllBytes(outpath_android, bytes);
            }
            if (source != outpath_ios)
            {
                FileHelper.WriteAllBytes(outpath_ios, bytes);
            }
        }
        else
        {
            //指定了直接 build
            ScriptBuildTools.BuildDll(outpath, mode);
        }
        //3.预绑定
        GenPreCLRBinding();
        //4.生成AnalysisCLRBinding
        GenCLRBindingByAnalysis();
        AssetDatabase.Refresh();
        Debug.Log("脚本打包完毕");
    }
 public void OnGUI()
 {
     GUILayout.BeginVertical();
     GUILayout.Label("3.表格打包", EditorGUIHelper.TitleStyle);
     GUILayout.Space(5);
     if (GUILayout.Button("表格导出成Sqlite", GUILayout.Width(300), GUILayout.Height(30)))
     {
         var outPath = Application.persistentDataPath + "/" + BDUtils.GetPlatformPath(RuntimePlatform.Android);
         //3.打包表格
         Excel2SQLiteTools.GenSQLite(outPath);
     }
     GUILayout.EndVertical();
 }
예제 #19
0
        /// <summary>
        /// 更新服务器配置
        /// </summary>
        /// <param name="callback"></param>
        /// <returns></returns>
        private IEnumerator UpdateServerConfig(Action callback)
        {
            var url = string.Format("{0}/{1}/{2}", FileServerUrl, BDUtils.GetPlatformPath(Application.platform), "GameConfig.json");

            Debug.Log(url);
            UnityWebRequest uwq     = UnityWebRequest.Get(url);
            GameConfig      gconfig = null;

            yield return(uwq.SendWebRequest());

            if (uwq.isDone && uwq.error == null)
            {
                var text = uwq.downloadHandler.text;
                if (!string.IsNullOrEmpty(text))
                {
                    gconfig = JsonMapper.ToObject <GameConfig>(text);
                    BDebug.Log("使用服务器配置:\n" + text);
                }
            }
            else
            {
                BDebug.LogError("Game配置无法更新,使用本地");
            }


            //TODO 未来改成反射实现,暂时用这一版
            if (gconfig != null)
            {
                this.CodeRoot = (AssetLoadPath)gconfig.CodeRoot;
                this.SQLRoot  = (AssetLoadPath)gconfig.SQLRoot;
                this.ArtRoot  = (AssetLoadPath)gconfig.ArtRoot;
                //
                this.CodeRunMode = (HotfixCodeRunMode)gconfig.CodeRunMode;
                //ip相关
                this.FileServerUrl = gconfig.FileServerUrl;
                this.IsHotfix      = gconfig.IsHotfix;
                this.GateServerIp  = gconfig.GateServerIp;
                this.Port          = gconfig.Port;
                if (!Application.isEditor)
                {
                    this.IsHotfix = this.IsNeedNet = true;
                }
            }

            if (callback != null)
            {
                callback();
            }
        }
        /// <summary>
        /// 打包资源
        /// </summary>
        public void BuildAsset()
        {
            if (isSelectAndroid)
            {
                AssetBundleEditorTools.GenAssetBundle(rootResourceDir,
                                                      exportPath + "/" + BDUtils.GetPlatformPath(RuntimePlatform.Android), BuildTarget.Android, options);
            }
            if (isSelectIOS)
            {
                AssetBundleEditorTools.GenAssetBundle(rootResourceDir,
                                                      exportPath + "/" + BDUtils.GetPlatformPath(RuntimePlatform.IPhonePlayer), BuildTarget.iOS, options);
            }

            AssetDatabase.Refresh();
            Debug.Log("资源打包完毕");
        }
예제 #21
0
        public static void GenxslxOrJsonToSQlite(IDictionary <string, string> path)
        {
            var outPath = IPath.Combine(Application.streamingAssetsPath,
                                        BDUtils.GetPlatformPath(Application.platform));
            var _path = IPath.Combine(outPath, "Local.db");

            sql = new SQLiteService(SqliteLoder.CreateConnetion(_path));
            foreach (var f in path)
            {
                Json2Sqlite(f.Key, f.Value);
            }

            sql.Close();
            EditorUtility.ClearProgressBar();
            Debug.Log("导出Sqlite完成!");
            AssetDatabase.Refresh();
        }
예제 #22
0
        public static void Json2SqliteQuick()
        {
            string path = AssetDatabase.GetAssetPath(Selection.activeObject);

            path = Path.GetFullPath(path);
            var outPath = IPath.Combine(Application.streamingAssetsPath,
                                        BDUtils.GetPlatformPath(Application.platform));
            var _path = IPath.Combine(outPath, "Local.db");

            sql = new SQLiteService(SqliteLoder.CreateConnetion(_path));
            string content = File.ReadAllText(path);

            Debug.Log(path);
            Json2Sqlite(path, content);
            sql.Close();
            EditorUtility.ClearProgressBar();
            Debug.Log("导出Sqlite完成!");
            AssetDatabase.Refresh();
        }
예제 #23
0
        public static void GenJsonToSQLite(List <string> paths)
        {
            var outPath = IPath.Combine(Application.streamingAssetsPath,
                                        BDUtils.GetPlatformPath(Application.platform));
            var _path = IPath.Combine(outPath, "Local.db");

            sql = new SQLiteService(SqliteLoder.CreateConnetion(_path));
            foreach (var f in paths)
            {
                string content = File.ReadAllText(f);

                Json2Sqlite(f, content);
            }

            sql.Close();
            EditorUtility.ClearProgressBar();
            Debug.Log("导出Sqlite完成!");
            AssetDatabase.Refresh();
        }
    /// <summary>
    /// 一键build所有资源
    /// </summary>
    public static void OneKeyBuildALLAssets_ForBuildPackage(RuntimePlatform platform, string outpath)
    {
        var outPath = outpath + "/" + BDUtils.GetPlatformPath(platform);

        //1.编译脚本
        ScriptBuildTools.BuildDll(Application.dataPath, outPath);
        EditorWindow_ScriptBuildDll.GenCLRBindingByAnalysis(platform);
        //2.打包资源
        if (platform == RuntimePlatform.IPhonePlayer)
        {
            AssetBundleEditorTools.GenAssetBundle("Resource/Runtime/", outPath, BuildTarget.iOS);
        }
        else if (platform == RuntimePlatform.Android)
        {
            AssetBundleEditorTools.GenAssetBundle("Resource/Runtime/", outPath, BuildTarget.Android);
        }
        //3.打包表格
        Excel2SQLiteTools.GenSQLite(outPath);
    }
예제 #25
0
        /// <summary>
        /// 生成所有资源
        /// </summary>
        /// <param name="exportPath"></param>
        /// <param name="platform"></param>
        /// <param name="target"></param>
        static public void GenAllAssets(string exportPath, RuntimePlatform platform, BuildTarget target)
        {
            var outPath = exportPath + "/" + BDUtils.GetPlatformPath(platform);

            if (Directory.Exists(outPath))
            {
                Directory.Delete(outPath, true);
            }
            //1.打包资源
            try
            {
                AssetBundleEditorTools.GenAssetBundle("Resource/Runtime/", outPath, target);
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                return;
            }

            //2.编译脚本
            try
            {
                var targetPath = exportPath + "/" + BDUtils.GetPlatformPath(platform);
                EditorWindow_ScriptBuildDll.RoslynBuild(ScriptBuildTools.BuildMode.Release, targetPath);
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                return;
            }

            //3.打包表格
            try
            {
                Excel2SQLiteTools.GenSQLite(outPath);
                Excel2SQLiteTools.CopyCurrentSqlToOther(outPath);
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
            }
        }
예제 #26
0
        /// <summary>
        /// 初始化DB
        /// </summary>
        /// <param name="str"></param>
        static public void Load(string root)
        {
            Connection?.Dispose();

            //先以外部传入的 作为 firstpath
            firstPath = IPath.Combine(root, BDUtils.GetPlatformPath(Application.platform) + "/Local.db");

            //firstpath不存在 或者 不支持io操作,
            //则默认情况生效,persistent为firstpath
            if (!File.Exists(firstPath))
            {
                //这里sqlite 如果不在firstPath下,就到Streamming下面拷贝到第一路径
                IEnumeratorTool.StartCoroutine(IE_LoadSqlite());
            }
            else
            {
                BDebug.Log("DB加载路径:" + firstPath, "red");
                Connection = new SQLiteConnection(firstPath, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create);
            }
        }
예제 #27
0
        public AssetBundleMgr(string root, Action onLoded)
        {
            //多热更切换,需要卸载
            if (this.config != null)
            {
                this.UnloadAllAsset();
                GC.Collect();
            }
            this.assetbundleMap   = new Dictionary <string, AssetBundleWapper>();
            this.allTaskGroupList = new List <LoaderTaskGroup>();
            //1.设置加载路径
            artRootPath    = (root + "/" + BDUtils.GetPlatformPath(Application.platform) + "/Art").Replace("\\", "/");
            secArtRootPath = (Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(Application.platform) + "/Art")
                             .Replace("\\", "/");
            //
            string configPath = FindAsset("Config.json");

            BDebug.Log("Art加载路径:" + configPath, "red");
            //
            this.config          = new AssetBundleManifestReference(configPath);
            this.config.OnLoaded = onLoded;
        }
예제 #28
0
        /// <summary>
        /// 修复模式,是要对比本地文件是否存在
        /// </summary>
        static public List <AssetItem> Repair(AssetConfig local, AssetConfig server)
        {
            if (local == null)
            {
                return(server.Assets);
            }

            var list = new List <AssetItem>();

            //比对平台
            if (local.Platfrom == server.Platfrom)
            {
                //平台
                var platform = BDUtils.GetPlatformPath(Application.platform);
                //
                foreach (var serverAsset in server.Assets)
                {
                    //比较本地是否有 hash、文件名一致的资源
                    var result = local.Assets.Find((a) => a.HashName == serverAsset.HashName && a.LocalPath == serverAsset.LocalPath);
                    //配置不存在
                    if (result == null)
                    {
                        list.Add(serverAsset);
                    }
                    else
                    {
                        //配置存在,判断文件存不存在,存在还要判断hash
                        var fs = localConfigRootPath + "/" + platform + "/" + serverAsset.LocalPath;
                        if (!File.Exists(fs))
                        {
                            list.Add(serverAsset);
                        }
                    }
                }
            }

            return(list);
        }
예제 #29
0
    public override void OnInspectorGUI()
    {
        //base.OnInspectorGUI();
        config = this.target as Config;

        var platform = BDUtils.GetPlatformPath(Application.platform);
        var filepath = Application.persistentDataPath + "/" + platform;

        GUILayout.Label(string.Format("当前资源路径:{0}", filepath));

        base.OnInspectorGUI();
        //


        if (GUILayout.Button("清空Persistent", GUILayout.Width(100), GUILayout.Height(20)))
        {
            Directory.Delete(Application.persistentDataPath, true);
        }

        if (GUILayout.Button("生成Config", GUILayout.Width(100), GUILayout.Height(20)))
        {
            GenGameConfig(Application.streamingAssetsPath, BDUtils.GetPlatformPath(RuntimePlatform.WindowsPlayer));
        }
    }
예제 #30
0
 public static void ExecuteJsonToSqlite()
 {
     Excel2SQLiteTools.GenJsonToSQLite(IPath.Combine(Application.streamingAssetsPath,
                                                     BDUtils.GetPlatformPath(Application.platform)));
     Debug.Log("表格导出完毕");
 }