private static PlayerSetting_Backup SettingToBuildConfig_EditorSetting(BuildConfig pBuildConfig, BuildTargetGroup eBuildTargetGroup) { string strDefineSymbol_Backup = PlayerSettings.GetScriptingDefineSymbolsForGroup(eBuildTargetGroup); PlayerSettings.SetScriptingDefineSymbolsForGroup(eBuildTargetGroup, pBuildConfig.strDefineSymbol); string strProductName_Backup = PlayerSettings.productName; PlayerSettings.productName = pBuildConfig.strProductName; return(new PlayerSetting_Backup(eBuildTargetGroup, strDefineSymbol_Backup, strProductName_Backup)); }
// ============================================================================================== #region private private static BuildPlayerOptions Generate_BuildPlayerOption(BuildConfig pBuildConfig, BuildTarget eBuildTarget, string strBuildPath) { BuildPlayerOptions sBuildPlayerOptions = new BuildPlayerOptions { scenes = pBuildConfig.arrBuildSceneNames.Select(p => p += ".unity").ToArray(), locationPathName = strBuildPath, target = eBuildTarget, options = BuildOptions.None }; return(sBuildPlayerOptions); }
private static void Process_PreBuild(BuildConfig pBuildConfig, string strAbsolute_BuildOutputFolderPath, string strFileName, BuildTarget eBuildTarget, out BuildTargetGroup eBuildTargetGroup, out string strBuildPath) { eBuildTargetGroup = GetBuildTargetGroup(eBuildTarget); strBuildPath = Create_BuildPath(pBuildConfig.bUse_DateTime_Suffix, strAbsolute_BuildOutputFolderPath, strFileName); switch (eBuildTarget) { case BuildTarget.Android: BuildSetting_Android(pBuildConfig.pAndroidSetting); strBuildPath += ".apk"; break; } }
public static void Create_BuildConfig_Dummy_Json() { string strContent = JsonUtility.ToJson(BuildConfig.CreateConfig(), true); string strFilePath = nameof(BuildConfig) + "_Example.json"; File.WriteAllText(Application.dataPath + "/" + strFilePath, strContent); AssetDatabase.Refresh(); UnityEngine.Object pJsonFile = AssetDatabase.LoadMainAssetAtPath($"Assets/{strFilePath}"); Selection.activeObject = pJsonFile; Debug.Log("Create BuildConfig Done", pJsonFile); }
/// <summary> /// <see> /// <cref>ScriptableObject.CreateInstance</cref> /// </see> /// Wrapper /// <para>ScriptableObject 생성시 생성자에 PlayerSettings에서 Get할경우 Unity Exception이 남</para> /// </summary> public static BuildConfig CreateConfig() { BuildConfig pConfig = ScriptableObject.CreateInstance <BuildConfig>(); pConfig.strProductName = PlayerSettings.productName; pConfig.arrBuildSceneNames = Builder.GetEnabled_EditorScenes(); pConfig.strAbsolute_BuildOutputFolderPath = Application.dataPath.Replace("/Assets", "") + "/Build"; pConfig.bUse_DateTime_Suffix = true; pConfig.pAndroidSetting = AndroidSetting.CreateSetting(); pConfig.pIOSSetting = IOSSetting.CreateSetting(); return(pConfig); }
public static void DoBuild(BuildConfig pBuildConfig, string strAbsolute_BuildOutputFolderPath, string strFileName, BuildTarget eBuildTarget) { g_pLastConfig = pBuildConfig; Process_PreBuild(pBuildConfig, strAbsolute_BuildOutputFolderPath, strFileName, eBuildTarget, out var eBuildTargetGroup, out var strBuildPath); BuildPlayerOptions sBuildPlayerOptions = Generate_BuildPlayerOption(pBuildConfig, eBuildTarget, strBuildPath); PlayerSetting_Backup pEditorSetting_Backup = SettingBuildConfig_To_EditorSetting(pBuildConfig, eBuildTargetGroup); Debug.LogFormat(const_strPrefix_ForDebugLog + " Before Build DefineSymbol TargetGroup : {0}\n" + "Origin Symbol : {1}\n " + "Config : {2} \n" + "Current : {3} \n" + "strBuildPath : {4}", eBuildTargetGroup, pEditorSetting_Backup.strDefineSymbol, pBuildConfig.strDefineSymbol, PlayerSettings.GetScriptingDefineSymbolsForGroup(eBuildTargetGroup), strBuildPath); try { BuildReport pReport = BuildPipeline.BuildPlayer(sBuildPlayerOptions); PrintBuildResult(strBuildPath, pReport, pReport.summary); } catch (Exception e) { Debug.Log(const_strPrefix_ForDebugLog + " Error - " + e); throw; } pEditorSetting_Backup.Back_To_Origin(); Process_PostBuild(eBuildTarget, strAbsolute_BuildOutputFolderPath); Debug.LogFormat(const_strPrefix_ForDebugLog + " After Build DefineSymbol Current {0}", PlayerSettings.GetScriptingDefineSymbolsForGroup(eBuildTargetGroup)); // 2018.4 에서 프로젝트 전체 리임포팅 하는 이슈 대응 // https://issuetracker.unity3d.com/issues/osx-batchmode-build-hangs-at-refresh-detecting-if-any-assets-need-to-be-imported-or-removed #if UNITY_EDITOR AssetDatabase.Refresh(); #endif }
private static void GetPath_FromConfig(BuildConfig pConfig, out string strBuildOutputFolderPath, out string strFileName) { string strBuildOutputFolderPath_CommandLine = GetCommandLineArg("-output_path"); string strFileName_CommandLine = GetCommandLineArg("-filename"); strBuildOutputFolderPath = string.IsNullOrEmpty(strBuildOutputFolderPath_CommandLine) ? pConfig.strAbsolute_BuildOutputFolderPath : strBuildOutputFolderPath_CommandLine; if (string.IsNullOrEmpty(strFileName_CommandLine)) { strFileName = pConfig.strFileName; } else { strFileName = strFileName_CommandLine; pConfig.bUse_DateTime_Suffix = false; } }
public static void GetAppFilePath_FromConfig(BuildConfig pConfig, out string strBuildOutputFolderPath, out string strFileName) { string strBuildOutputFolderPath_CommandLine = GetCommandLineArg(mapCommandLine[ECommandLineList.output_path]); string strFileName_CommandLine = GetCommandLineArg(mapCommandLine[ECommandLineList.filename]); strBuildOutputFolderPath = string.IsNullOrEmpty(strBuildOutputFolderPath_CommandLine) ? pConfig.strAbsolute_BuildOutputFolderPath : strBuildOutputFolderPath_CommandLine; if (string.IsNullOrEmpty(strFileName_CommandLine)) { strFileName = pConfig.strFileName; } else { strFileName = strFileName_CommandLine; pConfig.bUse_DateTime_Suffix = false; } }
public static void DoBuild(BuildConfig pBuildConfig, string strAbsolute_BuildOutputFolderPath, string strFileName, BuildTarget eBuildTarget) { g_pLastConfig = pBuildConfig; Process_PreBuild(pBuildConfig, strAbsolute_BuildOutputFolderPath, strFileName, eBuildTarget, out var eBuildTargetGroup, out var strBuildPath); BuildPlayerOptions sBuildPlayerOptions = Generate_BuildPlayerOption(pBuildConfig, eBuildTarget, strBuildPath); PlayerSetting_Backup pEditorSetting_Backup = SettingBuildConfig_To_EditorSetting(pBuildConfig, eBuildTargetGroup); Debug.LogFormat(const_strPrefix_ForDebugLog + " Before Build DefineSymbol TargetGroup : {0}\n" + "Origin Symbol : {1}\n " + "Config : {2} \n" + "Current : {3} \n" + "strBuildPath : {4}", eBuildTargetGroup, pEditorSetting_Backup.strDefineSymbol, pBuildConfig.strDefineSymbol, PlayerSettings.GetScriptingDefineSymbolsForGroup(eBuildTargetGroup), strBuildPath); try { BuildReport pReport = BuildPipeline.BuildPlayer(sBuildPlayerOptions); PrintBuildResult(strBuildPath, pReport, pReport.summary); } catch (Exception e) { Debug.Log(const_strPrefix_ForDebugLog + " Error - " + e); } pEditorSetting_Backup.Back_To_Origin(); Process_PostBuild(pBuildConfig, eBuildTarget, strAbsolute_BuildOutputFolderPath); Debug.LogFormat(const_strPrefix_ForDebugLog + " After Build DefineSymbol Current {0}", PlayerSettings.GetScriptingDefineSymbolsForGroup(eBuildTargetGroup)); }
// ============================================================================================== private static void Build(BuildConfig pBuildConfig, BuildTarget eBuildTarget) { BuildTargetGroup eBuildTargetGroup; string strBuildPath; Process_PreBuild(pBuildConfig, eBuildTarget, out eBuildTargetGroup, out strBuildPath); BuildPlayerOptions sBuildPlayerOptions = new BuildPlayerOptions(); sBuildPlayerOptions.scenes = pBuildConfig.arrBuildSceneNames; sBuildPlayerOptions.locationPathName = strBuildPath; sBuildPlayerOptions.target = eBuildTarget; sBuildPlayerOptions.options = BuildOptions.None; string strDefineSymbol_Backup = PlayerSettings.GetScriptingDefineSymbolsForGroup(eBuildTargetGroup); PlayerSettings.SetScriptingDefineSymbolsForGroup(eBuildTargetGroup, pBuildConfig.strDefineSymbol); Debug.LogFormat(const_strPrefix_ForDebugLog + " Before Build DefineSymbol TargetGroup : {0}\n" + "Origin Symbol : {1}\n " + "Config : {2} \n" + "Current : {3}", eBuildTargetGroup, strDefineSymbol_Backup, pBuildConfig.strDefineSymbol, PlayerSettings.GetScriptingDefineSymbolsForGroup(eBuildTargetGroup)); try { var pReport = BuildPipeline.BuildPlayer(sBuildPlayerOptions); PrintLog(strBuildPath, pReport, pReport.summary); } catch (Exception e) { Debug.Log(const_strPrefix_ForDebugLog + " Error - " + e); } PlayerSettings.SetScriptingDefineSymbolsForGroup(eBuildTargetGroup, strDefineSymbol_Backup); Process_PostBuild(pBuildConfig, eBuildTarget); Debug.LogFormat(const_strPrefix_ForDebugLog + " After Build DefineSymbol Current {0}", PlayerSettings.GetScriptingDefineSymbolsForGroup(eBuildTargetGroup)); }