Пример #1
0
        public void OnGUI_OneKeyExprot()
        {
            GUILayout.BeginVertical();
            {
                GUILayout.Label("注:上面按钮操作,会默认生成到StreamingAssets", GUILayout.Width(500), GUILayout.Height(30));
                isGenAndroidAssets = GUILayout.Toggle(isGenAndroidAssets, "生成Android资源(Windows公用)");
                isGenIosAssets     = GUILayout.Toggle(isGenIosAssets, "生成Ios资源");

                //
                GUILayout.Label("导出地址:" + exportPath, GUILayout.Width(500));
                //
                if (GUILayout.Button("一键导出", GUILayout.Width(350), GUILayout.Height(30)))
                {
                    //选择目录
                    exportPath = EditorUtility.OpenFolderPanel("选择导出目录", exportPath, "");
                    if (string.IsNullOrEmpty(exportPath))
                    {
                        return;
                    }



                    //生成android资源
                    if (isGenAndroidAssets)
                    {
                        GenAllAssets(exportPath, RuntimePlatform.Android, BuildTarget.Android);
                    }

                    //生成ios资源
                    if (isGenIosAssets)
                    {
                        GenAllAssets(exportPath, RuntimePlatform.IPhonePlayer, BuildTarget.iOS);
                    }

                    EditorUtility.DisplayDialog("提示", "资源导出完成", "OK");
                }

                //
                if (GUILayout.Button("热更资源转hash", GUILayout.Width(350), GUILayout.Height(30)))
                {
                    //选择目录
                    exportPath = EditorUtility.OpenFolderPanel("选择导出目录", exportPath, "");
                    if (string.IsNullOrEmpty(exportPath))
                    {
                        return;
                    }

                    //自动转hash
                    AssetUploadToServer.Assets2Hash(exportPath, "");
                }

                if (GUILayout.Button("上传到文件服务器[内网测试]", GUILayout.Width(350), GUILayout.Height(30)))
                {
                    //先不实现,等待使用者实现
                }
            }
            GUILayout.EndVertical();
        }
        public void OnGUI_OneKeyExprot()
        {
            GUILayout.BeginVertical();
            {
                GUILayout.Label("注:上面按钮操作,会默认生成到StreamingAssets", GUILayout.Width(500), GUILayout.Height(30));
                isGenAndroidAssets = GUILayout.Toggle(isGenAndroidAssets, "生成Android资源(Windows公用)");
                isGenIosAssets     = GUILayout.Toggle(isGenIosAssets, "生成Ios资源");

                //
                GUILayout.Label("导出地址:" + exportPath, GUILayout.Width(500));
                //
                if (GUILayout.Button("一键导出[自动转hash]", GUILayout.Width(350), GUILayout.Height(30)))
                {
                    //选择目录
                    exportPath = EditorUtility.OpenFolderPanel("选择导出目录", exportPath, "");
                    if (string.IsNullOrEmpty(exportPath))
                    {
                        return;
                    }

                    //开始生成资源
                    {
                        //生成android资源
                        if (isGenAndroidAssets)
                        {
                            var outPath = exportPath + "/" + BDUtils.GetPlatformPath(RuntimePlatform.Android);
                            //1.编译脚本
                            try
                            {
                                ScriptBuildTools.BuildDll(Application.dataPath, outPath);
                                EditorWindow_ScriptBuildDll.GenCLRBindingByAnalysis();
                            }
                            catch (Exception e)
                            {
                                Debug.LogError(e.Message);
                                return;
                            }

                            //2.打包资源
                            try
                            {
                                AssetBundleEditorTools.GenAssetBundle("Resource/Runtime/", outPath,
                                                                      BuildTarget.Android);
                            }
                            catch (Exception e)
                            {
                                Debug.LogError(e.Message);
                                return;
                            }

                            //3.打包表格
                            try
                            {
                                Excel2SQLiteTools.GenSQLite(outPath);
                            }
                            catch (Exception e)
                            {
                                Debug.LogError(e.Message);
                                return;
                            }
                        }

                        //生成ios资源
                        if (isGenIosAssets)
                        {
                            var outPath = exportPath + "/" + BDUtils.GetPlatformPath(RuntimePlatform.IPhonePlayer);
                            //1.编译脚本
                            try
                            {
                                ScriptBuildTools.BuildDll(Application.dataPath, outPath);
                                EditorWindow_ScriptBuildDll.GenCLRBindingByAnalysis();
                            }
                            catch (Exception e)
                            {
                                Debug.LogError(e.Message);
                                return;
                            }

                            //2.打包资源
                            try
                            {
                                AssetBundleEditorTools.GenAssetBundle("Resource/Runtime/", outPath, BuildTarget.iOS);
                            }
                            catch (Exception e)
                            {
                                Debug.LogError(e.Message);
                                return;
                            }

                            //3.打包表格
                            try
                            {
                                Excel2SQLiteTools.GenSQLite(outPath);
                            }
                            catch (Exception e)
                            {
                                Debug.LogError(e.Message);
                                return;
                            }
                        }
                    }

                    EditorUtility.DisplayDialog("提示", "资源导出完成", "OK");
                }

                //
                if (GUILayout.Button("上传到文件服务器[内网测试]", GUILayout.Width(350), GUILayout.Height(30)))
                {
                    //先不实现,等待使用者实现
                }

                if (GUILayout.Button("热更资源转hash[备用]", GUILayout.Width(350), GUILayout.Height(30)))
                {
                    //选择目录
                    exportPath = EditorUtility.OpenFolderPanel("选择导出目录", exportPath, "");
                    if (string.IsNullOrEmpty(exportPath))
                    {
                        return;
                    }

                    //自动转hash
                    AssetUploadToServer.Assets2Hash(exportPath, "");
                }
            }
            GUILayout.EndVertical();
        }