//-------------------------------------------------------------------------------------------- // 对选中的游戏打包: 启动程序/资源包/场景包 void OnBuildSelGame(Rect rct) { if (GUI.Button(rct, @"全部制作")) { string szMsg = ""; List <TglItem> selGms = mGameLst.GetSelItems(); if (selGms.Count <= 0) { szMsg = @"没有需要构建的游戏"; EditorUtility.DisplayDialog(@"操作提示", szMsg, "Ok"); return; } szMsg = @"确定要构建选中的游戏吗? 这个过程会很漫长,请耐心等待直到弹出结果窗口."; if (EditorUtility.DisplayDialog(@"游戏发布", szMsg, "Ok", "Cancel")) { int nCount = 0; foreach (TglItem itm in selGms) { GamePackUI gm = null; string sGm = ArchiveUtil.GetLastPath(itm.mName); if (mGameRes.TryGetValue(sGm.ToLower(), out gm)) { ++nCount; gm.BuildGameAndPack(mTgtCtrl.GetSelTarget()); } } szMsg = @"消息: 成功打包 ["; szMsg += (nCount.ToString() + @"] 个游戏, 有 ["); szMsg += ((selGms.Count - nCount).ToString() + @"] 个游戏打包失败"); EditorUtility.DisplayDialog(@"操作已结束", szMsg, "Ok"); } } }
//----------------------------------------------------------------------------- // 打包场景(*.unity)资源 public void OnBuildScene(BuildTarget tgt) { List <string> vScn = new List <string>(); List <TglItem> vItms = mScnCtrl.GetSelItems(); foreach (TglItem itm in vItms) { string sf = GetGamePath() + itm.mName; vScn.Add(sf); } string szTgtNm = BuildGameCMD.GetTargetName(tgt); string szPath = BuildGameCMD.GetBuildFolder(tgt); string szDefaultPath = BuildGameCMD.GetBuildFolder(mGmWind.GetTarget()); string saveFolder = EditorUtility.SaveFolderPanel("Save Pack File", szDefaultPath, ""); if (saveFolder == "") { return; } m_versionControl.LoadProject(saveFolder); if (mbSingle) { string file = EditorUtility.SaveFilePanel("Save Scene File", szPath, mGame + szTgtNm, "unity3d"); if (file.Length > 0) { BuildGameCMD.BuildGameScene(file, vScn, tgt, m_versionControl); } } else { string szMsg; int nCount = 0; foreach (string sf in vScn) { string nsf = szPath + "/" + ArchiveUtil.GetFileName(sf) + ".unity3d"; szMsg = BuildGameCMD.BuildGameScene(nsf, sf, tgt, m_versionControl); if (!string.IsNullOrEmpty(szMsg)) { Debug.LogWarning("BuildGameScene Msg = " + szMsg); } else { ++nCount; } } szMsg = @"消息: 成功打包 ["; szMsg += (nCount.ToString() + @"] 个场景, 有 ["); szMsg += ((vScn.Count - nCount).ToString() + @"] 个场景打包失败"); EditorUtility.DisplayDialog(@"操作已结束", szMsg, "Ok"); } m_versionControl.SaveProject(saveFolder); }
void NtfBuildResPack() { string sPth = GetGamePath(); if (m_useConfig) { //sPth = Application.dataPath+"/"; } List <string> vPths = mGmWind.GetPublicPath(false); // 选中的公共资源列表 List <string> vfs = ArchiveUtil.NtfGetFiles(sPth, false, ArchiveUtil.mSkips); List <TglItem> vItms = mPthCtrl.GetSelItems(); string szDefaultPath = BuildGameCMD.GetBuildFolder(mGmWind.GetTarget()); string saveFolder = EditorUtility.SaveFolderPanel("Save Pack File", szDefaultPath, ""); if (saveFolder == "") { return; } m_versionControl.LoadProject(saveFolder); foreach (TglItem itm in vItms) { string selPath = itm.mName; vPths.Clear(); vPths.Add(sPth + selPath); string saveFileName = saveFolder + "/" + selPath.Replace('/', '_') + ".pack"; PackageVersion.Version cfgPackage = new PackageVersion.Version(); cfgPackage.Init(); cfgPackage.m_isAliveInRuntime = itm.m_isPackedAlive; cfgPackage.m_isExternPackage = itm.m_isPackedExtern; if (itm.mIsPackedEachFile) { NtfPackEachFile(sPth + selPath, saveFolder, mGmWind.GetTarget(), true, m_versionControl, cfgPackage); } else { NtfPack(vPths, vfs, saveFileName, mGmWind.GetTarget(), true, m_versionControl, cfgPackage); } } m_versionControl.SaveProject(saveFolder); EditorUtility.DisplayDialog(@"操作提示", @"打包完成", "Ok"); }