Exemple #1
0
    public void BuildAssetBundle(bool clearOldBundle)
    {
        Debug.LogWarning("BuildAssetBundle-----------------------------------");

        //*****************读取以前列表文件信息********************
        string manifest = BundleTools.GetBuildBundlePath(isStaticAsset) + "/" + assetFileTool;

        localManifest = AssetFileTool.LoadFromFile(manifest);


        BundleTools.CreateBuildBundleDir(isStaticAsset);
        if (clearOldBundle)
        {
            BundleTools.ClearBuildBundleDir(isStaticAsset);
        }

        BuildTarget             platform = EditorUserBuildSettings.activeBuildTarget;
        BuildAssetBundleOptions babo     = BuildAssetBundleOptions.ChunkBasedCompression;

        System.DateTime dt         = System.DateTime.Now;
        string          targetPath = BundleTools.GetBuildBundlePath(isStaticAsset);

        BuildPipeline.BuildAssetBundles(targetPath, babo, platform);
        Debug.Log("Build bundle cost time: " + (DateTime.Now - dt).TotalSeconds + "s");

        AssetBundleNameSet.ClearAllBundleName();        //清除

        AssetDatabase.Refresh();
    }
    public void BuildName(string[] buildAssetPath, bool isStaticAsset)
    {
        AssetBundleNameSet.ClearAllBundleName();        //清除


        System.DateTime dt = System.DateTime.Now;
        Debug.Log("clear time: " + (System.DateTime.Now - dt).TotalSeconds);

        bundleName.Clear();
        resNumber = 0;
        dependence.Clear();
        originRes.Clear();


        this.SetAssetBundleName(buildAssetPath); //Bundle命名
        this.SetSceneAssetBundleName();          //场景Bundle命名
        if (isStaticAsset)
        {
            this.SetDirAssetBundleName(Application.dataPath + "/Resources/Lua/", "lua");             //Lua的Bundle命名
        }
        else
        {
//			this.SetDirAssetBundleName (Application.dataPath + "/Client/DynamicResources/Empty/", "empty");
        }

        Debug.Log("<color=yellow>all asset number " + resNumber + "</color>");


        bundleName.Clear();
        resNumber = 0;
        dependence.Clear();
        originRes.Clear();

        AssetDatabase.RemoveUnusedAssetBundleNames();

        Debug.Log("set name done! time: " + (System.DateTime.Now - dt).TotalSeconds);
    }
Exemple #3
0
    void OnGUI()
    {
        GUILayout.Label("目标平台: " + BundleTools.GetTargetPlatform(), EditorStyles.boldLabel, GUILayout.Height(20));
        GUILayout.Label("AppVersion: " + VersionTool.packageVersion, EditorStyles.boldLabel, GUILayout.Height(20));
        GUILayout.Label("StaticResVersion: " + StaticResVersion, EditorStyles.boldLabel, GUILayout.Height(20));
        string rv  = EditorGUILayout.TextField(StaticResVersion.ToString(), GUILayout.Width(30));
        int    irv = -1;

        if (int.TryParse(rv, out irv))
        {
            StaticResVersion = irv;
        }

        GUILayout.Label("DynamicResVersion: " + DynamicResVersion, EditorStyles.boldLabel, GUILayout.Height(20));
        rv  = EditorGUILayout.TextField(DynamicResVersion.ToString(), GUILayout.Width(30));
        irv = -1;
        if (int.TryParse(rv, out irv))
        {
            DynamicResVersion = irv;
        }

        GUILayout.Label("当前Bundle数量: " + AssetDatabase.GetAllAssetBundleNames().Length, EditorStyles.boldLabel, GUILayout.Height(20));
        assetPath               = GUILayout.TextArea(assetPath);
        isStaticAsset           = GUILayout.Toggle(isStaticAsset, "静态资源(对应生成静态或动态资源的mainfest文件)");
        buildEmptyDynamicAssets = DynamicResVersion == 0;
        buildEmptyStaticAssets  = StaticResVersion == 0;
        #region 打包流程


        GUILayout.Space(10);
        if (GUILayout.Button("工具——清除Bundle命名"))
        {
            AssetBundleNameSet.ClearAllBundleName();            //清除
        }

        GUILayout.Space(10);
        if (GUILayout.Button("打包流程0=>copy lua文件"))
        {
            CopyLuaFiile();
        }

        GUILayout.Space(10);
        if (GUILayout.Button("打包流程①=>Bundle命名"))
        {
            AssetBundleName();
        }

        GUILayout.Space(10);
        if (GUILayout.Button("打包流程②=>生成assetbundle"))
        {
            BuildAssetBundle(true);
        }

        GUILayout.Space(10);
        if (GUILayout.Button("打包流程③=>生成资源列表文件"))
        {
            CreateManifest();
        }

        GUILayout.Space(10);

        if (GUILayout.Button("打包流程④=>拷贝资源列表到工程"))
        {
            CopyAssetmainifestListToProject();
        }

        GUILayout.Space(10);
        GUILayout.Space(10);
        GUILayout.Space(10);

        #endregion


        #region 一键生成资源包不COPY资源列表


        if (GUILayout.Button("一键生成资源包不COPY资源列表(主要用于在本地测试Static资源是否能正常下载使用)"))
        {
            if (isStaticAsset)
            {
                CopyLuaFiile();
            }
            AssetBundleName();
            BuildAssetBundle(true);
            CreateManifest();
            //CopyAssetmainifestListToProject();
        }

        #endregion

        #region 一键生成资源包


        if (GUILayout.Button("一键生成Bundle资源"))
        {
            if (isStaticAsset)
            {
                CopyLuaFiile();
            }
            AssetBundleName();
            BuildAssetBundle(true);
            CreateManifest();
            CopyAssetmainifestListToProject();
        }

        #endregion
    }