//-------------------------------------------------------------------------------------------- // 打包场景文件 static public void BuildGameScene(string file, List <string> fLst, BuildTarget tgt, GameBundleVersionControl version) { //BuildOptions op = BuildOptions.BuildAdditionalStreamedScenes; //string szMsg = BuildPipeline.BuildPlayer(fLst.ToArray(), file, tgt, op); file = file.ToLower(); string pkgName = Path.GetFileName(file); pkgName = pkgName.ToLower(); bool needPackage = false; foreach (string n in fLst) { string sceneFileName = ArchiveUtil.NtfPathAfterAssets(n).ToLower(); if (version.UpdateFileMD5(sceneFileName, pkgName)) { needPackage = true; break; } } if (!needPackage) { return; } string szMsg = BuildPipeline.BuildStreamedSceneAssetBundle(fLst.ToArray(), file, tgt); if (string.IsNullOrEmpty(szMsg)) { AppendResPackItm(fLst.ToArray(), file, tgt); version.IncreasePackageVersion(pkgName); szMsg = @"操作成功"; } EditorUtility.DisplayDialog(@"操作已结束", @"消息: " + szMsg, "Ok"); }
//-------------------------------------------------------------------------------------------- // 生成对应文件的 Object 对象 static public List <Object> BuildObjectList(ref BuildArgs vArgs, BundleVersionControl version, ref bool isNeedPackage) { isNeedPackage = false; string szPckNm = Path.GetFileName(vArgs.vPack); szPckNm = szPckNm.ToLower(); List <Object> objList = new List <Object>(); foreach (string fileName in vArgs.fAry) { string szt = fileName.ToLower(); if (szt.EndsWith(".unity")) { Debug.LogWarning("BuildPipeline Skip file = " + fileName); continue; } if (szt.EndsWith(".unitypackage")) { Debug.LogWarning("BuildPipeline Skip file = " + fileName); continue; } string fl = ArchiveUtil.NtfPathBeginAssets(fileName); fl = fl.Replace('\\', '/'); string szKey = ArchiveUtil.NtfPathAfterAssets(fl).ToLower(); if (version != null && version.UpdateFileMD5(szKey, szPckNm) == false) {//MD5相同,不用打包 } else { isNeedPackage = true; } Object obj = AssetDatabase.LoadMainAssetAtPath(fl); if (null == obj) { Debug.LogWarning("BuildPipeline LOAD failed file = " + fileName); continue; } objList.Add(obj); vArgs.kAry.Add(szKey); ResPackItm itm = new ResPackItm(); itm.mType = 0; // 普通资源 itm.mfVer = 1; //// 需要查找对应版本号 itm.mFile = szKey; itm.mPack = szPckNm; vArgs.vTbl.Add(szKey, itm); } //更新package对应的版本号 if (version != null && isNeedPackage) { version.IncreasePackageVersion(szPckNm); } return(objList); }
//----------------------------------------------------------------------------- // 找到当前游戏的启动场景 !!!! 这里要按游戏来搜索 !!!! string FindGameLaunch() { string sLaunch = ""; string szPth = Application.dataPath;//GetGamePath();// Application.dataPath; List <string> vAry = ArchiveUtil.NtfGetFiles(szPth, true, "*.unity"); foreach (string sPth in vAry) { string sf = sPth.ToLower(); if (sf.Contains("launch")) { sLaunch = sPth; break; } } //sLaunch = ArchiveUtil.NtfPathAfter(szPth, sLaunch); sLaunch = ArchiveUtil.NtfPathAfterAssets(sLaunch); return(sLaunch); }
//-------------------------------------------------------------------------------------------- // 刷新游戏列表 void NtfRefreshGames() { mpSelGM = null; mGameRes.Clear(); mGameLst.ResetCtrl(); List <string> pths = ArchiveUtil.NtfGetDirs(Application.dataPath, false, ArchiveUtil.mSkips); foreach (string sPth in pths) { string sl = sPth.ToLower(); if (sl.Contains("package") || sl.Contains("resources") || sl.Contains("extends")) { mGameLst.AddItem(new TglItem(sPth)); string sGm = ArchiveUtil.GetLastPath(sPth); string sPt = ArchiveUtil.NtfPathAfterAssets(sPth); GamePackUI gpu = new GamePackUI(sGm, sPt, this); mGameRes.Add(sGm.ToLower(), gpu); } } OnFirstGame(); }
static public string BuildGameScene(string file, string szScene, BuildTarget tgt, GameBundleVersionControl version) { file = file.ToLower(); string pkgName = Path.GetFileName(file); pkgName = pkgName.ToLower(); string sceneFileName = ArchiveUtil.NtfPathAfterAssets(szScene).ToLower(); if (!version.UpdateFileMD5(sceneFileName, pkgName)) { return(""); } string[] szAry = new string[] { szScene }; string szMsg = BuildPipeline.BuildStreamedSceneAssetBundle(szAry, file, tgt); if (string.IsNullOrEmpty(szMsg)) { AppendResPackItm(szAry, file, tgt); version.IncreasePackageVersion(pkgName); } return(szMsg); }