Example #1
0
    private void DrawDebugTool()
    {
        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical(opt);
        if (GUILayout.Button("发布Lua文件", opt))
        {
            if (!StreamPack.PackStreamData())
            {
                EditorUtility.DisplayDialog("", "打包Lua失败", "OK");
            }
            else
            {
                EditorUtility.DisplayDialog("", "操作成功,请继续执行“发布资源文件”", "OK");
            }
        }
        if (GUILayout.Button("发布资源文件", opt))
        {
            PackageAssetBundle(currentBuildTarget);
            PackageShader(currentBuildTarget);
            EditorUtility.DisplayDialog("", "操作成功,请继续执行“生成更新检测文件”", "OK");
            return;
        }
        if (GUILayout.Button("生成更新检测文件", opt))
        {
            CreateMD5List.Execute(currentBuildTarget);
            EditorUtility.DisplayDialog("", "操作成功,请继续执行“效验更新检测文件”", "OK");
        }

        if (GUILayout.Button("效验更新检测文件", opt))
        {
            CampareMD5ToGenerateVersionNum.Execute(currentBuildTarget);
            EditorUtility.DisplayDialog("", "资源发布完成!", "OK");
        }

        GUILayout.Space(70f);
        if (GUILayout.Button("一键发布", opt))
        {
            if (StreamPack.PackStreamData() &&
                PackageAssetBundle(currentBuildTarget) && PackageShader(currentBuildTarget) &&
                CreateMD5List.Execute(currentBuildTarget) && CampareMD5ToGenerateVersionNum.Execute(currentBuildTarget))
            {
                EditorUtility.DisplayDialog("", "一键发布完成!", "OK");
            }
            else
            {
                EditorUtility.DisplayDialog("", "一键发布失败!", "OK");
            }
        }
        GUILayout.EndHorizontal();
    }
Example #2
0
    /// <summary>
    /// assetbundle打包
    /// </summary>
    /// <param name="target">目标平台</param>
    public static void Execute(UnityEditor.BuildTarget target)
    {
        BundleConfigManager.ReadConfig();

        Dictionary <string, List <string> > bundles = BundleConfigManager.Bundles;
        string savePath = BundleConfigManager.SavePath + AssetBundleController.GetPlatformName(target) + '/';

        if (!Directory.Exists(savePath))
        {
            Directory.CreateDirectory(savePath);
        }

        if (bundles.Count <= 0)
        {
            Debug.LogError(BundleConfigManager.ConfigFileName + " is empty.");
            return;
        }

        //打包
        foreach (KeyValuePair <string, List <string> > bundle in bundles)
        {
            List <Object> objs = new List <Object>();
            foreach (string path in bundle.Value)
            {
                FillObjToList(path, objs);
            }
            BuildPipeline.BuildAssetBundle(objs[0], objs.ToArray(), savePath + bundle.Key + ".assetbundle", _option, target);
        }

        //计算MD5
        CreateMD5List.Execute(target);

        //比较MD5
        CampareMD5ToGenerateVersionNum.Execute(target);

        //修改Version文件
        CreateAssetBundleForXmlVersion.Execute(target);

        // scene目录下的资源
        AssetDatabase.Refresh();
    }
Example #3
0
    //导出单个文件资源包
    public static void ExportFileAssetBundles(Dictionary <string, Dictionary <string, List <string> > > bundles)
    {
        UnityEngine.Debug.ClearDeveloperConsole();
        Caching.CleanCache();
        if (bundles.Count > 0)
        {
            int createdBundles = 0;
            int allBundles     = bundles.Count;
            foreach (KeyValuePair <string, Dictionary <string, List <string> > > bundle in bundles)
            {
                string        bundleName = bundle.Key;
                bool          result     = true;
                List <Object> assets     = new List <Object>();
                foreach (KeyValuePair <string, List <string> > bundleFolder in bundle.Value)
                {
                    List <string> assetNamesInFolder = bundleFolder.Value;
                    foreach (string assetName in assetNamesInFolder)
                    {
                        string folderName     = assetName;
                        int    directoryStart = assetName.IndexOf("Assets");
                        folderName = assetName.Remove(0, directoryStart);
                        string thisFileName = Path.GetFileName(assetName);
                        if (assetName.EndsWith(".prefab"))
                        {
                            string internalFilePath = folderName;
                            //Debug.Log("internalFilePath1==================="+internalFilePath);
                            GameObject prefab = AssetDatabase.LoadAssetAtPath(internalFilePath, typeof(GameObject)) as GameObject;
                            assets.Add(prefab);
                        }
                        else if (!assetName.EndsWith(".meta") && thisFileName.IndexOf(".") != -1)
                        {
                            string internalFilePath = folderName;
                            //Debug.Log("internalFilePath2==================="+internalFilePath);
                            assets.Add(AssetDatabase.LoadAssetAtPath(internalFilePath, typeof(Object)));
                        }
                        if (EditorTools.mBuildType == EditorTools.BuildType.BT_ExportFiles)
                        {
                            GetDependencies(bundleName, folderName, ref result);
                        }
                    }
                    if (EditorTools.mBuildType == EditorTools.BuildType.BT_ExportFolders)
                    {
                        GetDependencies(bundleName, assetNamesInFolder, ref result);
                    }
                }
                if (!result)
                {
                    Debug.Log("bundleName : " + bundleName + "  文件没有变动!!!");
                    continue;
                }
                //string path = Application.dataPath + EditorTools.m_sExportFolderLocationFloder;
                string path = EditorTools.mExportFolderLocationFloder;

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                if (!BuildAssetBundle(assets, path + bundleName))
                {
                    continue;
                }
                Debug.Log("资源:  " + bundleName + "  导出完毕!  适用于:" + EditorTools.mBuildTarget + " 平台!");
                string MD5Hash = EditorTools.GetMD5Hash(path + bundleName);
                Debug.Log("MD5Hash:" + MD5Hash);
                createdBundles++;
            }
            if (createdBundles > 0)
            {
                Debug.Log("***本地 资源 成功打包: " + createdBundles + "/" + allBundles + " 场景资源!***");
            }
        }
        else
        {
            Debug.Log("没有资源可以打包!请选择资源!");
        }
        CreateMD5List.Execute(EditorTools.mBuildTarget);
        CampareMD5ToGenerateVersionNum.Execute(EditorTools.mBuildTarget);
        AssetDatabase.Refresh();
    }