예제 #1
0
    public static bool BundleData()
    {
        bool bSuccess = true;

        System.DateTime lastTime = System.DateTime.Now;
        string          sOutDir  = AppPackage.AddStamp(ms_sDataOutDir);

        BuildAssetBundleOptions theAssetOptions = BuildAssetBundleOptions.ForceRebuildAssetBundle;

        //theAssetOptions = theAssetOptions | BuildAssetBundleOptions.CompleteAssets;
        //theAssetOptions = theAssetOptions | BuildAssetBundleOptions.CollectDependencies;
        theAssetOptions = theAssetOptions | BuildAssetBundleOptions.UncompressedAssetBundle;
        theAssetOptions = theAssetOptions | BuildAssetBundleOptions.DeterministicAssetBundle;

        List <string> lstFiles = new List <string>();

        string[] mediaFiles = AppPackage.GetFiles(new string[] { ms_sMediaDir }, new string[] { "*.ogg", "*.mp3" }, true);
        lstFiles.AddRange(mediaFiles);

        string[] objFiles = AppPackage.GetFiles(new string[] { ms_sObjDir }, new string[] { "*.prefab" }, true);
        lstFiles.AddRange(objFiles);

        string[] effectFiles = AppPackage.GetFiles(new string[] { ms_sEffectDir }, new string[] { "*.prefab" }, true);
        lstFiles.AddRange(effectFiles);

        string[] charFiles = AppPackage.GetFiles(new string[] { ms_sCharDir }, new string[] { "*.prefab" }, true);
        lstFiles.AddRange(charFiles);

        string[] uiFiles = AppPackage.GetFiles(new string[] { ms_sUIDir }, new string[] { "*.prefab", "*.png", "*.jpg", "*.ttf" }, true);
        lstFiles.AddRange(uiFiles);

        /*string[] cfgFiles = GetFiles(new string[] { ms_sConfigDir }, new string[] { "*.prefab", "*.json", "*.bytes" }, true);
         * lstFiles.AddRange(cfgFiles);*/

        string[] mapFiles = AppPackage.GetFiles(new string[] { ms_sMapDir }, new string[] { "*.prefab" }, true);
        lstFiles.AddRange(mapFiles);

        AppPackage.DeleteABManifest(sOutDir + ms_sMediaDir.ToLower());
        AppPackage.DeleteABManifest(sOutDir + ms_sObjDir.ToLower());
        AppPackage.DeleteABManifest(sOutDir + ms_sEffectDir.ToLower());
        AppPackage.DeleteABManifest(sOutDir + ms_sCharDir.ToLower());
        //AppPackage.DeleteABManifest(sOutDir + ms_sConfigDir.ToLower());
        AppPackage.DeleteABManifest(sOutDir + ms_sMapDir.ToLower());

        AppPackage.DeleteABManifest(null, sOutDir + GameConfigMgr.ms_sABMFileName);
        string[] depFiles = AssetDatabase.GetDependencies(lstFiles.ToArray());
        string[] files    = AppPackage.GetMatch(depFiles, new string[] { "^.+\\.ogg$|^.+\\.mp3$|^.+\\.prefab$|^.+\\.png$|^.+\\.jpg$|^.+\\.ttf$|^.+\\.json$|^.+\\.bytes$|^.+\\.renderTexture$" });
        AppPackage.BundleFiles(sOutDir, files, theAssetOptions, false);
        bSuccess &= AppPackage.BackUpABManifest(sOutDir, sOutDir + GameConfigMgr.ms_sABMFileName + GameConfigMgr.ms_sABType);
        if (!bSuccess)
        {
            return(false);
        }

        System.TimeSpan costTime = System.DateTime.Now - lastTime;
        Debug.Log("-->> BundleData Cost: " + (costTime.Hours * 3600 + costTime.Minutes * 60 + costTime.Seconds).ToString() + "s");
        return(true);
    }
예제 #2
0
    public static bool BundleLuaCsv()
    {
        System.DateTime lastTime           = System.DateTime.Now;
        string          sOutDir            = AppPackage.AddStamp(ms_sDataOutDir);
        string          sDataLuaScriptPath = ms_sDataDir + ms_sLuaScriptName;
        string          sDataDesignerPath  = ms_sDataDir + ms_sDesignerName;
        bool            bSuccess           = true;

        bSuccess &= AppPackage.LuaToByteCode(ms_sLuaScriptDir, sDataLuaScriptPath, ms_sLuaScriptName, ms_ArrGacLuaCheck);
        bSuccess &= AppPackage.LuaToByteCode(ms_sDesignerDir, sDataDesignerPath, ms_sDesignerName, new string[] { "/Config/" });

        AssetDatabase.Refresh();
        if (!bSuccess)
        {
            return(false);
        }

        BuildAssetBundleOptions theAssetOptions = BuildAssetBundleOptions.ForceRebuildAssetBundle;

        //theAssetOptions = theAssetOptions | BuildAssetBundleOptions.CompleteAssets;
        //theAssetOptions = theAssetOptions | BuildAssetBundleOptions.CollectDependencies;
        theAssetOptions = theAssetOptions | BuildAssetBundleOptions.UncompressedAssetBundle;
        theAssetOptions = theAssetOptions | BuildAssetBundleOptions.DeterministicAssetBundle;

        // Lua Handle
        AppPackage.DeleteABManifest(sOutDir + ms_sLuaScriptName.ToLower(), sOutDir + GameConfigMgr.ms_sLuaMFileName);
        string[] luaFilesList = AppPackage.GetFiles(new string[] { sDataLuaScriptPath }, new string[] { "*.bytes" }, true);
        AppPackage.BundleFiles(sOutDir, luaFilesList, theAssetOptions, false);
        bSuccess &= AppPackage.BackUpABManifest(sOutDir, sOutDir + GameConfigMgr.ms_sLuaMFileName + GameConfigMgr.ms_sABType);
        if (!bSuccess)
        {
            return(false);
        }

        // Csv Handle
        AppPackage.DeleteABManifest(sOutDir + ms_sDesignerName.ToLower(), sOutDir + GameConfigMgr.ms_sCsvMFileName);
        string[] csvFilesList = AppPackage.GetFiles(new string[] { sDataDesignerPath }, new string[] { "*.bytes" }, true);
        AppPackage.BundleFiles(sOutDir, csvFilesList, theAssetOptions, false);
        bSuccess &= AppPackage.BackUpABManifest(sOutDir, sOutDir + GameConfigMgr.ms_sCsvMFileName + GameConfigMgr.ms_sABType);
        if (!bSuccess)
        {
            return(false);
        }

        //Clean LuaCsv Temp Files
        if (Directory.Exists(sDataLuaScriptPath))
        {
            Directory.Delete(sDataLuaScriptPath, true);
            File.Delete(sDataLuaScriptPath + ms_sMetaExt);
        }
        if (Directory.Exists(sDataDesignerPath))
        {
            Directory.Delete(sDataDesignerPath, true);
            File.Delete(sDataDesignerPath + ms_sMetaExt);
        }
        AssetDatabase.Refresh();

        System.TimeSpan costTime = System.DateTime.Now - lastTime;
        Debug.Log("-->> BundleLuaCsv Cost: " + (costTime.Hours * 3600 + costTime.Minutes * 60 + costTime.Seconds).ToString() + "s");
        return(true);
    }