public static GetExtensionForBuildTarget ( BuildTarget target, BuildOptions options ) : string | ||
target | BuildTarget | |
options | BuildOptions | |
Результат | string |
internal static bool ValidateLocationPathNameForBuildTargetGroup(string locationPathName, BuildTargetGroup buildTargetGroup, BuildTarget target, BuildOptions options, out string errorMessage) { if (string.IsNullOrEmpty(locationPathName)) { var willInstallInBuildFolder = (options & BuildOptions.InstallInBuildFolder) != 0 && PostprocessBuildPlayer.SupportsInstallInBuildFolder(buildTargetGroup, target); if (!willInstallInBuildFolder) { errorMessage = "The 'locationPathName' parameter for BuildPipeline.BuildPlayer should not be null or empty."; return(false); } } else if (string.IsNullOrEmpty(Path.GetFileName(locationPathName))) { var extensionForBuildTarget = PostprocessBuildPlayer.GetExtensionForBuildTarget(buildTargetGroup, target, options); if (!string.IsNullOrEmpty(extensionForBuildTarget)) { errorMessage = string.Format( "For the '{0}' target the 'locationPathName' parameter for BuildPipeline.BuildPlayer should not end with a directory separator.\n" + "Provided path: '{1}', expected a path with the extension '.{2}'.", target, locationPathName, extensionForBuildTarget); return(false); } } errorMessage = ""; return(true); }
private static string BuildPlayer(string[] scenes, string locationPathName, string assetBundleManifestPath, BuildTarget target, BuildOptions options) { if (string.IsNullOrEmpty(locationPathName)) { if (!(((options & BuildOptions.InstallInBuildFolder) != BuildOptions.CompressTextures) && PostprocessBuildPlayer.SupportsInstallInBuildFolder(target))) { return("The 'locationPathName' parameter for BuildPipeline.BuildPlayer should not be null or empty."); } } else if (string.IsNullOrEmpty(Path.GetFileName(locationPathName))) { string extensionForBuildTarget = PostprocessBuildPlayer.GetExtensionForBuildTarget(target, options); if (!string.IsNullOrEmpty(extensionForBuildTarget)) { return($"For the '{target}' target the 'locationPathName' parameter for BuildPipeline.BuildPlayer should not end with a directory separator. Provided path: '{locationPathName}', expected a path with the extension '.{extensionForBuildTarget}'."); } } try { return(BuildPlayerInternal(scenes, locationPathName, assetBundleManifestPath, target, options).SummarizeErrors()); } catch (Exception exception) { LogBuildExceptionAndExit("BuildPipeline.BuildPlayer", exception); return(""); } }
private static string BuildPlayer(string[] scenes, string locationPathName, string assetBundleManifestPath, BuildTarget target, BuildOptions options) { string result; if (string.IsNullOrEmpty(locationPathName)) { if ((options & BuildOptions.InstallInBuildFolder) == BuildOptions.None || !PostprocessBuildPlayer.SupportsInstallInBuildFolder(target)) { result = "The 'locationPathName' parameter for BuildPipeline.BuildPlayer should not be null or empty."; return(result); } } else if (string.IsNullOrEmpty(Path.GetFileName(locationPathName))) { string extensionForBuildTarget = PostprocessBuildPlayer.GetExtensionForBuildTarget(target, options); if (!string.IsNullOrEmpty(extensionForBuildTarget)) { result = string.Format("For the '{0}' target the 'locationPathName' parameter for BuildPipeline.BuildPlayer should not end with a directory separator.\nProvided path: '{1}', expected a path with the extension '.{2}'.", target, locationPathName, extensionForBuildTarget); return(result); } } try { result = BuildPipeline.BuildPlayerInternal(scenes, locationPathName, assetBundleManifestPath, target, options).SummarizeErrors(); } catch (Exception exception) { BuildPipeline.LogBuildExceptionAndExit("BuildPipeline.BuildPlayer", exception); result = ""; } return(result); }
private static bool PickBuildLocation(BuildTargetGroup targetGroup, BuildTarget target, BuildOptions options, out bool updateExistingBuild) { updateExistingBuild = false; var previousPath = EditorUserBuildSettings.GetBuildLocation(target); string defaultFolder; string defaultName; if (previousPath == String.Empty) { defaultFolder = FileUtil.DeleteLastPathNameComponent(Application.dataPath); defaultName = ""; } else { defaultFolder = FileUtil.DeleteLastPathNameComponent(previousPath); defaultName = FileUtil.GetLastPathNameComponent(previousPath); } string extension = PostprocessBuildPlayer.GetExtensionForBuildTarget(targetGroup, target, options); // Invalidate default name, if extension mismatches the default file (for ex., when switching between folder type export to file type export, see Android) if (extension != Path.GetExtension(defaultName).Replace(".", "")) { defaultName = string.Empty; } // Hack: For Windows Standalone, we want the BuildPanel to choose a folder, // but we don't want BuildPlayer to take a folder path because historically it took an .exe path // and we would be breaking tons of projects! bool isWindowsStandalone = target == BuildTarget.StandaloneWindows || target == BuildTarget.StandaloneWindows64; string realExtension = extension; if (isWindowsStandalone) { extension = string.Empty; // Remove the filename.exe part from the path if (!string.IsNullOrEmpty(defaultName)) { defaultName = Path.GetDirectoryName(defaultName); } } string title = "Build " + BuildPlatforms.instance.GetBuildTargetDisplayName(targetGroup, target); string path = EditorUtility.SaveBuildPanel(target, title, defaultFolder, defaultName, extension, out updateExistingBuild); if (path == string.Empty) { return(false); } if (isWindowsStandalone) { extension = realExtension; path = Path.Combine(path, Paths.MakeValidFileName(PlayerSettings.productName) + '.' + extension); } if (!IsBuildPathValid(path)) { return(false); } // Enforce extension if needed if (extension != string.Empty && FileUtil.GetPathExtension(path).ToLower() != extension) { path += '.' + extension; } // A path may not be empty initially, but it could contain, e.g., a drive letter (as in Windows), // so even appending an extension will work fine, but in reality the name will be, for example, // G:/ //Debug.Log(path); string currentlyChosenName = FileUtil.GetLastPathNameComponent(path); if (currentlyChosenName == string.Empty) { return(false); // No nameless projects, please } // We don't want to re-create a directory that already exists, this may // result in access-denials that will make users unhappy. string check_dir = extension != string.Empty ? FileUtil.DeleteLastPathNameComponent(path) : path; if (!Directory.Exists(check_dir)) { Directory.CreateDirectory(check_dir); } // On OSX we've got replace/update dialog, for other platforms warn about deleting // files in target folder. if ((target == BuildTarget.iOS) && (Application.platform != RuntimePlatform.OSXEditor)) { if (!FolderIsEmpty(path) && !UserWantsToDeleteFiles(path)) { return(false); } } EditorUserBuildSettings.SetBuildLocation(target, path); return(true); }