Exemplo n.º 1
0
    void OnWizardCreate()
    {
        string strTarget = System.Enum.GetName(typeof(BuildTarget), target);

        if (strTarget == null || strTarget == "")
        {
            return;
        }
        CreateMD5List.Execute(target);
    }
Exemplo n.º 2
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();
    }
Exemplo n.º 3
0
    public static void BuildAssetBundles()
    {
        // Choose the output path according to the build target.
        string outputPath = Path.Combine(kAssetBundlesOutputPath, ResourceLoader.GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget));

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

        BuildPipeline.BuildAssetBundles(outputPath, 0, EditorUserBuildSettings.activeBuildTarget);

        CreateMD5List.Execute(outputPath);
    }
Exemplo n.º 4
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(40f, 20f, 200f, 50f), "创建assetbundle散包"))
        {
            CreateAssetBundle.Execute(buildTarget);
            EditorUtility.DisplayDialog("", "创建assetbundle散包", "OK");
        }
        if (GUI.Button(new Rect(40f, 90f, 200f, 50f), "创建assetbundle整包"))
        {
            string filename = EditorUtility.SaveFilePanel("", AssetBundleController.GetPlatformPath(buildTarget), "输入bundle名称,点击保存", "assetbundle");
            CreateAssetBundle.ExecuteAll(filename, buildTarget);
            EditorUtility.DisplayDialog("", filename, "OK");
        }
        if (GUI.Button(new Rect(300f, 20f, 200f, 50f), "一键所有prefab散包"))
        {
            VisualAutuPack.Execute(buildTarget);
            //CreateAssetBundle.Execute(buildTarget);
            //EditorUtility.DisplayDialog("", "创建assetbundle散包", "OK");
        }
        if (GUI.Button(new Rect(300f, 90f, 200f, 50f), "删除动作组件"))
        {
            bool isOk = EditorUtility.DisplayDialog("删除动作组件", "警告:不可逆过程,需要通过svn才能还原!确定要删除所有动作组件吗", "确定", "取消");
            if (isOk)
            {
                VisualAutuPack.DelAnimationComponent();
            }
        }
        if (GUI.Button(new Rect(300f, 160f, 200f, 50f), "一键所有动作组件bundle"))
        {
            VisualAutuPack.ExecuteAnim(buildTarget);
        }
        if (GUI.Button(new Rect(40f, 160f, 200f, 50f), "资源加密"))
        {
            CreateAssetBundle.ExecuteEncryption(buildTarget);
        }

        if (GUI.Button(new Rect(40f, 230f, 200f, 50f), "生成 MD5"))
        {
            CreateMD5List.Execute(buildTarget);
            EditorUtility.DisplayDialog("", "MD5 生成OK", "OK");
        }
    }
Exemplo n.º 5
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();
    }
Exemplo n.º 6
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();
    }