// 유틸 : App 빌드 static void BuildApplication(string[] strScenes, BuildTarget eTarget, BuildOptions eOptions) { string strBuildName = GetBuildName(eTarget, Single.AppInfo.GetAppName(), Single.Table.GetClientVersion()); Debug.LogFormat("** Build Start({0}) -> {1}", strBuildName, DateTime.Now.ToString("yyyy-MM-dd [ HH:mm:ss ]")); { EditorUserBuildSettings.SwitchActiveBuildTarget(eTarget); string strFileName = string.Format("{0}/{1}", SHPath.GetPathToBuild(), strBuildName); if (false == SHUtils.IsExistsDirectory(strFileName)) { eOptions = BuildOptions.None; } SHUtils.CreateDirectory(strFileName); string strResult = BuildPipeline.BuildPlayer(strScenes, strFileName, eTarget, eOptions); if (0 < strResult.Length) { throw new Exception("BuildPlayer failure: " + strResult); } } Debug.LogFormat("** Build End({0}) -> {1}", strBuildName, DateTime.Now.ToString("yyyy-MM-dd [ HH:mm:ss ]")); }
static void BuildApplication(string[] strScenes, BuildTarget eTarget, BuildOptions eOptions) { string strBuildName = GetBuildName(eTarget, Single.AppInfo.GetProductName()); Debug.LogFormat("** [SHBuilder] Build Start({0}) -> {1}", strBuildName, DateTime.Now.ToString("yyyy-MM-dd [ HH:mm:ss ]")); { if (BuildTarget.Android == eTarget) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, eTarget); } else { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, eTarget); } string strExportPath = string.Format("{0}/{1}/{2}", SHPath.GetBuild(), SHUtils.GetPlatformStringByEnum(eTarget), strBuildName); SHUtils.CreateDirectory(strExportPath); BuildReport pReport = BuildPipeline.BuildPlayer(strScenes, strExportPath, eTarget, eOptions); if (BuildResult.Failed == pReport.summary.result) { throw new Exception("[SHBuilder] BuildPlayer failure: BuildPipeline.BuildPlayer"); } } Debug.LogFormat("** [SHBuilder] Build End({0}) -> {1}", strBuildName, DateTime.Now.ToString("yyyy-MM-dd [ HH:mm:ss ]")); }
// 유틸 : 번들 패킹 시작 및 아웃풋 static bool MakeAssetBundle(BuildTarget eTarget, string strOutputPath, Dictionary <string, AssetBundleInfo> dicBundles) { // 디렉토리 정리 SHUtils.DeleteDirectory(strOutputPath); SHUtils.CreateDirectory(strOutputPath); // 번들 빌드 정보 만들기 List <AssetBundleBuild> pBuildList = new List <AssetBundleBuild>(); SHUtils.ForToDic(dicBundles, (pKey, pValue) => { List <string> pAssets = new List <string>(); SHUtils.ForToDic(pValue.m_dicResources, (pResKey, pResValue) => { pAssets.Add(string.Format("{0}/{1}{2}", "Assets/Resources", pResValue.m_strPath, pResValue.m_strExtension)); }); AssetBundleBuild pAssetInfo = new AssetBundleBuild(); pAssetInfo.assetBundleName = string.Format("{0}.unity3d", pValue.m_strBundleName); pAssetInfo.assetNames = pAssets.ToArray(); pBuildList.Add(pAssetInfo); }); // 빌드할 번들이 없으면 종료 if (0 == pBuildList.Count) { return(true); } // 번들 빌드하기 AssetBundleManifest pManifest = BuildPipeline.BuildAssetBundles(strOutputPath, pBuildList.ToArray(), BuildAssetBundleOptions.DeterministicAssetBundle, eTarget); if (null == pManifest) { Debug.LogErrorFormat("Error!!! Make Assets Bundle : {0}", strOutputPath); return(false); } // 후 처리 SHUtils.ForToList(pBuildList, (pBundle) => { // 번들 크기와 해시코드 기록 string strKey = pBundle.assetBundleName.Substring(0, pBundle.assetBundleName.Length - ".unity3d".Length).ToLower(); if (true == dicBundles.ContainsKey(strKey)) { dicBundles[strKey].m_pHash128 = pManifest.GetAssetBundleHash(pBundle.assetBundleName); dicBundles[strKey].m_lBundleSize = (new FileInfo(string.Format("{0}/{1}", strOutputPath, pBundle.assetBundleName))).Length; } // Manifest제거 ( 사용하지 않는 불필요한 파일이라 그냥 제거시킴 ) SHUtils.DeleteFile(string.Format("{0}/{1}.manifest", strOutputPath, pBundle.assetBundleName)); }); SHUtils.DeleteFile(string.Format("{0}/{1}", strOutputPath, SHHard.GetStrToPlatform(eTarget))); SHUtils.DeleteFile(string.Format("{0}/{1}.manifest", strOutputPath, SHHard.GetStrToPlatform(eTarget))); return(true); }
static void PackingAssetBundles(BuildTarget eTarget, eBundlePackType eType) { Debug.LogFormat("** [SHBuilder] AssetBundles Packing Start({0}) -> {1}", eTarget, DateTime.Now.ToString("yyyy-MM-dd [ HH:mm:ss ]")); { string strExportPath = string.Format("{0}/{1}/{2}", SHPath.GetBuild(), SHUtils.GetPlatformStringByEnum(eTarget), "AssetBundle"); SHUtils.CreateDirectory(strExportPath); BuildPipeline.BuildAssetBundles(strExportPath, BuildAssetBundleOptions.None, eTarget); } Debug.LogFormat("** [SHBuilder] AssetBundles Packing End({0}) -> {1}", eTarget, DateTime.Now.ToString("yyyy-MM-dd [ HH:mm:ss ]")); }
public static void CopyFile(string strSource, string strDest) { if (false == File.Exists(strSource)) { return; } SHUtils.CreateDirectory(strDest); File.Copy(strSource, strDest, true); // ICloud에 백업 안되게 파일에 대해 SetNoBackupFlag를 해주자!! #if UNITY_IPHONE UnityEngine.iOS.Device.SetNoBackupFlag(strDest); #endif }
public static void SaveByte(byte[] pBytes, string strSavePath) { SHUtils.CreateDirectory(strSavePath); var pFile = new FileStream(strSavePath, FileMode.Create, FileAccess.Write); var pWriter = new BinaryWriter(pFile); pWriter.Write(pBytes); pWriter.Close(); pFile.Close(); // ICloud에 백업 안되게 파일에 대해 SetNoBackupFlag를 해주자!! #if UNITY_IPHONE UnityEngine.iOS.Device.SetNoBackupFlag(strSavePath); #endif UnityEngine.Debug.Log(string.Format("[LSH] {0} Byte 저장", strSavePath)); }
public static void SaveFile(string strBuff, string strSavePath) { SHUtils.CreateDirectory(strSavePath); var pFile = new FileStream(strSavePath, FileMode.Create, FileAccess.Write); var pWriter = new StreamWriter(pFile); pWriter.WriteLine(strBuff); pWriter.Close(); pFile.Close(); // ICloud에 백업 안되게 파일에 대해 SetNoBackupFlag를 해주자!! #if UNITY_IPHONE UnityEngine.iOS.Device.SetNoBackupFlag(strSavePath); #endif UnityEngine.Debug.Log(string.Format("{0} File 저장", strSavePath)); }