예제 #1
0
    public static void BuildAssetBundles_PC()
    {
#if UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX
        var tab = CleanAndGenXMLRawInfo(AssetBundlePathResolver.BundlePCSavedPath);
        if (tab == null)
        {
            return;
        }

        ABBuilder builder = new AssetBundleBuilder5x_PC();
        builder.BundleSavePath         = AssetBundlePathResolver.BundlePCSavedPath;
        builder.AssetBundleRawInfoList = tab;

        AssetBundleManifest manifest = null;

        if (tab.Count > 0)
        {
            builder.Begin();
            try
            {
                manifest = builder.Export();
            }
            catch (System.Exception e)
            {
                CommonLog.Error(e);
            }

            if (manifest != null)
            {
                builder.End(manifest, true);
            }
            else
            {
                CommonLog.Error("manifest 为空");
            }
        }
        else
        {
            CommonLog.Warning(string.Format("本次导出没有生成文件"));
        }

        EditorUtility.ClearProgressBar();
        AssetDatabase.Refresh();
        CommonLog.Log("资源打包完成!");
        return;
#else
        CommonLog.Error("请先切换到对应PC平台");
#endif
    }
예제 #2
0
    public static void AutoBuildAssetBundles_PC(bool forceRebuild = false)
    {
        //判断是不是PC平台
        if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows ||
            EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64 ||
            EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneOSX ||
            EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneLinux64)
        {
            var tab = RefreshNewNameAndGetAssetBundleList();
            CheckBundleTableAboutShortMD5Repeat(tab);
            AssetDatabase.Refresh();

            ABBuilder builder = new AssetBundleBuilder5x_PC();
            builder.BundleSavePath         = AssetBundlePathResolver.BundlePCSavedPath;
            builder.AssetBundleRawInfoList = tab;

            AssetBundleManifest manifest = null;

            if (tab.Count > 0)
            {
                builder.Begin();
                try
                {
                    manifest = builder.Export(forceRebuild);
                }
                catch (System.Exception e)
                {
                    CommonLog.Error(e);
                }

                builder.End(manifest, true);
            }
            else
            {
                CommonLog.Warning(string.Format("本次导出没有生成文件"));
            }

            AssetDatabase.Refresh();
            EditorUtility.ClearProgressBar();
            CommonLog.Log("资源打包完成!");
            return;
        }

        CommonLog.Error("请先切换到对应PC平台");
    }