public string this[BuildTarget index] { get { return(this[BuildTargetUtility.TargetToGroup(index)]); } set { this[BuildTargetUtility.TargetToGroup(index)] = value; } }
private bool IsEqual(AudioImporter target) { AudioImporter reference = referenceImporter as AudioImporter; UnityEngine.Assertions.Assert.IsNotNull(reference); if (!IsEqualAudioSampleSetting(target.defaultSampleSettings, reference.defaultSampleSettings)) { return(false); } foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups) { var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g, BuildTargetUtility.PlatformNameType.AudioImporter); if (target.ContainsSampleSettingsOverride(platformName) != reference.ContainsSampleSettingsOverride(platformName)) { return(false); } if (target.ContainsSampleSettingsOverride(platformName)) { var t = target.GetOverrideSampleSettings(platformName); var r = reference.GetOverrideSampleSettings(platformName); if (!IsEqualAudioSampleSetting(t, r)) { return(false); } } } if (target.forceToMono != reference.forceToMono) { return(false); } // using "!UNITY_5_6_OR_NEWER" instead of "Unity_5_6" because loadInBackground became obsolete after Unity 5.6b3. #if !UNITY_5_6_OR_NEWER if (target.loadInBackground != reference.loadInBackground) { return(false); } #endif #if UNITY_2017_1_OR_NEWER if (target.ambisonic != reference.ambisonic) { return(false); } #endif if (target.preloadAudioData != reference.preloadAudioData) { return(false); } return(true); }
public override void Build(BuildTarget target, Model.NodeData node, IEnumerable <PerformGraph.AssetGroups> incoming, IEnumerable <Model.ConnectionData> connectionsToOutput, PerformGraph.Output Output, Action <Model.NodeData, string, float> progressFunc) { if (incoming == null) { return; } if (!Directory.Exists(m_buildLocations[target])) { Directory.CreateDirectory(m_buildLocations[target]); } var sceneGUIDs = m_scenes[target].Split(','); #if UNITY_5_5_OR_NEWER string manifestPath = string.Empty; foreach (var ag in incoming) { foreach (var assets in ag.assetGroups.Values) { var manifestBundle = assets.Where(a => a.assetType == typeof(AssetBundleManifestReference)); if (manifestBundle.Any()) { manifestPath = manifestBundle.First().importFrom; } } } BuildPlayerOptions opt = new BuildPlayerOptions(); opt.options = (BuildOptions)m_buildOptions[target]; opt.locationPathName = m_buildLocations[target] + "/" + m_playerName[target]; opt.assetBundleManifestPath = manifestPath; opt.scenes = sceneGUIDs.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).Where(path => !string.IsNullOrEmpty(path) && !path.Contains("__DELETED_GUID_Trash")).ToArray(); opt.target = target; #if UNITY_5_6_OR_NEWER opt.targetGroup = BuildTargetUtility.TargetToGroup(target); #endif var errorMsg = BuildPipeline.BuildPlayer(opt); #else string[] levels = sceneGUIDs.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).Where(path => !string.IsNullOrEmpty(path) && !path.Contains("__DELETED_GUID_Trash")).ToArray(); string locationPathName = m_buildLocations[target] + "/" + m_playerName[target]; BuildOptions opt = (BuildOptions)m_buildOptions[target]; var errorMsg = BuildPipeline.BuildPlayer(levels, locationPathName, target, opt); #endif if (!string.IsNullOrEmpty(errorMsg)) { throw new NodeException(node.Name + ":Player build failed:" + errorMsg, node.Id); } }
private string GetManifestName(BuildTarget target) { if (string.IsNullOrEmpty(m_outputDir [target])) { return(BuildTargetUtility.TargetToAssetBundlePlatformName(target)); } else { return(Path.GetFileName(m_outputDir [target])); } }
public static bool IsBuildTargetSupported(BuildTarget t) { var objType = typeof(UnityEditor.BuildPipeline); var method = objType.GetMethod("IsBuildTargetSupported", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); #if UNITY_5_6 || UNITY_5_6_OR_NEWER BuildTargetGroup g = BuildTargetUtility.TargetToGroup(t); //internal static extern bool IsBuildTargetSupported (BuildTargetGroup buildTargetGroup, BuildTarget target); var retval = method.Invoke(null, new object[] { System.Enum.ToObject(typeof(BuildTargetGroup), g), System.Enum.ToObject(typeof(BuildTarget), t) }); #else //internal static extern bool IsBuildTargetSupported (BuildTarget target); var retval = method.Invoke(null, new object[] { System.Enum.ToObject(typeof(BuildTarget), t) }); #endif return(Convert.ToBoolean(retval)); }
private void OverwriteImportSettings(AudioImporter importer) { var reference = referenceImporter as AudioImporter; UnityEngine.Assertions.Assert.IsNotNull(reference); importer.defaultSampleSettings = reference.defaultSampleSettings; importer.forceToMono = reference.forceToMono; importer.preloadAudioData = reference.preloadAudioData; foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups) { var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g, BuildTargetUtility.PlatformNameType.AudioImporter); if (reference.ContainsSampleSettingsOverride(platformName)) { var setting = reference.GetOverrideSampleSettings(platformName); if (!importer.SetOverrideSampleSettings(platformName, setting)) { LogUtility.Logger.LogError("AudioImporter", string.Format("Failed to set override setting for {0}: {1}", platformName, importer.assetPath)); } } else { importer.ClearSampleSettingOverride(platformName); } } // using "!UNITY_5_6_OR_NEWER" instead of "Unity_5_6" because loadInBackground became obsolete after Unity 5.6b3. #if !UNITY_5_6_OR_NEWER importer.loadInBackground = reference.loadInBackground; #endif #if UNITY_2017_1_OR_NEWER importer.ambisonic = reference.ambisonic; #endif }
public void SetupSupportedBuildTargets() { if (supportedBuildTargets == null) { supportedBuildTargets = new List <BuildTarget>(); supportedBuildTargetGroups = new List <BuildTargetGroup>(); try { foreach (BuildTarget target in Enum.GetValues(typeof(BuildTarget))) { if (BuildTargetUtility.IsBuildTargetSupported(target)) { if (!supportedBuildTargets.Contains(target)) { supportedBuildTargets.Add(target); } BuildTargetGroup g = BuildTargetUtility.TargetToGroup(target); if (g == BuildTargetGroup.Unknown) { // skip unknown platform continue; } if (!supportedBuildTargetGroups.Contains(g)) { supportedBuildTargetGroups.Add(g); } } } supportedBuildTargetNames = new string[supportedBuildTargets.Count]; for (int i = 0; i < supportedBuildTargets.Count; ++i) { supportedBuildTargetNames[i] = BuildTargetUtility.TargetToHumaneString(supportedBuildTargets[i]); } } catch (Exception e) { LogUtility.Logger.LogError(LogUtility.kTag, e); } } }
private bool IsEqual(TextureImporter target, bool ignorePackingTagDifference) { TextureImporter reference = referenceImporter as TextureImporter; UnityEngine.Assertions.Assert.IsNotNull(reference); // UnityEditor.TextureImporter.textureFormat' is obsolete: // `textureFormat is not longer accessible at the TextureImporter level if (target.textureType != reference.textureType) { return(false); } TextureImporterSettings targetSetting = new TextureImporterSettings(); TextureImporterSettings referenceSetting = new TextureImporterSettings(); target.ReadTextureSettings(targetSetting); reference.ReadTextureSettings(referenceSetting); if (!TextureImporterSettings.Equal(targetSetting, referenceSetting)) { return(false); } if (target.textureType == TextureImporterType.Sprite) { if (target.spritePackingTag != reference.spritePackingTag) { return(false); } var s1 = target.spritesheet; var s2 = reference.spritesheet; if (s1.Length != s2.Length) { return(false); } for (int i = 0; i < s1.Length; ++i) { if (s1 [i].alignment != s2 [i].alignment) { return(false); } if (s1 [i].border != s2 [i].border) { return(false); } if (s1 [i].name != s2 [i].name) { return(false); } if (s1 [i].pivot != s2 [i].pivot) { return(false); } if (s1 [i].rect != s2 [i].rect) { return(false); } } } if (target.wrapMode != reference.wrapMode) { return(false); } if (target.anisoLevel != reference.anisoLevel) { return(false); } if (target.borderMipmap != reference.borderMipmap) { return(false); } if (target.compressionQuality != reference.compressionQuality) { return(false); } if (target.convertToNormalmap != reference.convertToNormalmap) { return(false); } if (target.fadeout != reference.fadeout) { return(false); } if (target.filterMode != reference.filterMode) { return(false); } if (target.generateCubemap != reference.generateCubemap) { return(false); } if (target.heightmapScale != reference.heightmapScale) { return(false); } if (target.isReadable != reference.isReadable) { return(false); } if (target.maxTextureSize != reference.maxTextureSize) { return(false); } if (target.mipMapBias != reference.mipMapBias) { return(false); } if (target.mipmapEnabled != reference.mipmapEnabled) { return(false); } if (target.mipmapFadeDistanceEnd != reference.mipmapFadeDistanceEnd) { return(false); } if (target.mipmapFadeDistanceStart != reference.mipmapFadeDistanceStart) { return(false); } if (target.mipmapFilter != reference.mipmapFilter) { return(false); } if (target.normalmapFilter != reference.normalmapFilter) { return(false); } if (target.npotScale != reference.npotScale) { return(false); } if (target.spriteBorder != reference.spriteBorder) { return(false); } if (target.spriteImportMode != reference.spriteImportMode) { return(false); } if (!ignorePackingTagDifference && target.spritePackingTag != reference.spritePackingTag) { return(false); } if (target.spritePivot != reference.spritePivot) { return(false); } if (target.spritePixelsPerUnit != reference.spritePixelsPerUnit) { return(false); } /* read only properties */ // target.qualifiesForSpritePacking #if !UNITY_5_5_OR_NEWER // obsolete features if (target.normalmap != reference.normalmap) { return(false); } if (target.linearTexture != reference.linearTexture) { return(false); } if (target.lightmap != reference.lightmap) { return(false); } if (target.grayscaleToAlpha != reference.grayscaleToAlpha) { return(false); } if (target.generateMipsInLinearSpace != reference.generateMipsInLinearSpace) { return(false); } if (target.textureFormat != reference.textureFormat) { return(false); } foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups) { var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g, BuildTargetUtility.PlatformNameType.TextureImporter); int srcMaxTextureSize; TextureImporterFormat srcFormat; int srcCompressionQuality; int dstMaxTextureSize; TextureImporterFormat dstFormat; int dstCompressionQuality; var srcHasSetting = target.GetPlatformTextureSettings(platformName, out srcMaxTextureSize, out srcFormat, out srcCompressionQuality); var dstHasSetting = reference.GetPlatformTextureSettings(platformName, out dstMaxTextureSize, out dstFormat, out dstCompressionQuality); if (srcHasSetting != dstHasSetting) { return(false); } if (srcMaxTextureSize != dstMaxTextureSize) { return(false); } if (srcFormat != dstFormat) { return(false); } if (srcCompressionQuality != dstCompressionQuality) { return(false); } } #else if (target.allowAlphaSplitting != reference.allowAlphaSplitting) { return(false); } if (target.alphaIsTransparency != reference.alphaIsTransparency) { return(false); } if (target.textureShape != reference.textureShape) { return(false); } if (target.alphaSource != reference.alphaSource) { return(false); } if (target.sRGBTexture != reference.sRGBTexture) { return(false); } if (target.textureCompression != reference.textureCompression) { return(false); } if (target.crunchedCompression != reference.crunchedCompression) { return(false); } foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups) { var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g, BuildTargetUtility.PlatformNameType.TextureImporter); var impSet = reference.GetPlatformTextureSettings(platformName); var targetImpSet = target.GetPlatformTextureSettings(platformName); if (!CompareImporterPlatformSettings(impSet, targetImpSet)) { return(false); } } #endif #if UNITY_2017_1_OR_NEWER if (target.alphaTestReferenceValue != reference.alphaTestReferenceValue) { return(false); } if (target.mipMapsPreserveCoverage != reference.mipMapsPreserveCoverage) { return(false); } if (target.wrapModeU != reference.wrapModeU) { return(false); } if (target.wrapModeV != reference.wrapModeV) { return(false); } if (target.wrapModeW != reference.wrapModeW) { return(false); } #endif return(true); }
private void OverwriteImportSettings(VideoClipImporter importer) { var reference = referenceImporter as VideoClipImporter; UnityEngine.Assertions.Assert.IsNotNull(reference); /* * defaultTargetSettings Default values for the platform-specific import settings. * deinterlaceMode Images are deinterlaced during transcode. This tells the importer how to interpret fields in the source, if any. * flipHorizontal Apply a horizontal flip during import. * flipVertical Apply a vertical flip during import. * frameCount Number of frames in the clip. * frameRate Frame rate of the clip. * importAudio Import audio tracks from source file. * isPlayingPreview Whether the preview is currently playing. * keepAlpha Whether to keep the alpha from the source into the transcoded clip. * linearColor Used in legacy import mode. Same as MovieImport.linearTexture. * outputFileSize Size in bytes of the file once imported. * quality Used in legacy import mode. Same as MovieImport.quality. * sourceAudioTrackCount Number of audio tracks in the source file. * sourceFileSize Size in bytes of the file before importing. * sourceHasAlpha True if the source file has a channel for per-pixel transparency. * useLegacyImporter Whether to import a MovieTexture (legacy) or a VideoClip. */ importer.defaultTargetSettings = reference.defaultTargetSettings; importer.deinterlaceMode = reference.deinterlaceMode; importer.flipHorizontal = reference.flipHorizontal; importer.flipVertical = reference.flipVertical; importer.importAudio = reference.importAudio; importer.keepAlpha = reference.keepAlpha; importer.linearColor = reference.linearColor; importer.quality = reference.quality; importer.useLegacyImporter = reference.useLegacyImporter; #if UNITY2017_2_OR_NEWER importer.pixelAspectRatioDenominator = reference.pixelAspectRatioDenominator; importer.pixelAspectRatioNumerator = reference.pixelAspectRatioNumerator; #endif foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups) { var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g, BuildTargetUtility.PlatformNameType.VideoClipImporter); try { var setting = reference.GetTargetSettings(platformName); if (setting != null) { importer.SetTargetSettings(platformName, setting); } else { importer.ClearTargetSettings(platformName); } } catch (Exception e) { LogUtility.Logger.LogWarning("VideoClipImporter", string.Format("Failed to set override setting for platform {0}: file :{1} \\nreason:{2}", platformName, importer.assetPath, e.Message)); } } /* read only */ /* * importer.frameCount * importer.frameRate * importer.isPlayingPreview * importer.outputFileSize * importer.sourceAudioTrackCount * importer.sourceFileSize * importer.sourceHasAlpha */ }
public bool IsEqual(VideoClipImporter target) { VideoClipImporter reference = referenceImporter as VideoClipImporter; UnityEngine.Assertions.Assert.IsNotNull(reference); if (!IsEqual(target.defaultTargetSettings, reference.defaultTargetSettings)) { return(false); } /* read only properties. ImportSettingConfigurator will not use these properties for diff. */ /* * importer.frameCount * importer.frameRate * importer.isPlayingPreview * importer.outputFileSize * importer.sourceAudioTrackCount * importer.sourceFileSize * importer.sourceHasAlpha */ if (target.deinterlaceMode != reference.deinterlaceMode) { return(false); } if (target.flipHorizontal != reference.flipHorizontal) { return(false); } if (target.flipVertical != reference.flipVertical) { return(false); } if (target.importAudio != reference.importAudio) { return(false); } if (target.keepAlpha != reference.keepAlpha) { return(false); } if (target.linearColor != reference.linearColor) { return(false); } if (target.quality != reference.quality) { return(false); } if (target.useLegacyImporter != reference.useLegacyImporter) { return(false); } #if UNITY2017_2_OR_NEWER if (target.pixelAspectRatioDenominator != reference.pixelAspectRatioDenominator) { return(false); } if (target.pixelAspectRatioNumerator != reference.pixelAspectRatioNumerator) { return(false); } #endif foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups) { var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g, BuildTargetUtility.PlatformNameType.VideoClipImporter); try { var r = reference.GetTargetSettings(platformName); var t = target.GetTargetSettings(platformName); if (!IsEqual(r, t)) { return(false); } } catch (Exception e) { LogUtility.Logger.LogWarning("VideoClipImporter", string.Format("Failed to set override setting for platform {0}: file :{1} \\nreason:{2}", platformName, target.assetPath, e.Message)); } } return(true); }
public static string EnsureAssetBundleCacheDirExists(BuildTarget t, Model.NodeData node, bool remake = false) { var cacheDir = FileUtility.PathCombine(Model.Settings.Path.BundleBuilderCachePath, node.Id, BuildTargetUtility.TargetToAssetBundlePlatformName(t)); if (!Directory.Exists(cacheDir)) { Directory.CreateDirectory(cacheDir); } else { if (remake) { RemakeDirectory(cacheDir); } } return(cacheDir); }
public void Set(BuildTarget t, object value) { Set(BuildTargetUtility.TargetToGroup(t), value); }
public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { if (m_enabledBundleOptions == null) { return; } EditorGUILayout.HelpBox("Build Asset Bundles: Build asset bundles with given asset bundle settings.", MessageType.Info); editor.UpdateNodeName(node); bool newOverwrite = EditorGUILayout.ToggleLeft("Keep AssetImporter settings for variants", m_overwriteImporterSetting); if (newOverwrite != m_overwriteImporterSetting) { using (new RecordUndoScope("Remove Target Bundle Options", node, true)){ m_overwriteImporterSetting = newOverwrite; onValueChanged(); } } GUILayout.Space(10f); //Show target configuration tab editor.DrawPlatformSelector(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var disabledScope = editor.DrawOverrideTargetToggle(node, m_enabledBundleOptions.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) => { using (new RecordUndoScope("Remove Target Bundle Options", node, true)){ if (enabled) { m_enabledBundleOptions[editor.CurrentEditingGroup] = m_enabledBundleOptions.DefaultValue; m_outputDir[editor.CurrentEditingGroup] = m_outputDir.DefaultValue; m_outputOption[editor.CurrentEditingGroup] = m_outputOption.DefaultValue; } else { m_enabledBundleOptions.Remove(editor.CurrentEditingGroup); m_outputDir.Remove(editor.CurrentEditingGroup); m_outputOption.Remove(editor.CurrentEditingGroup); } onValueChanged(); } }); using (disabledScope) { OutputOption opt = (OutputOption)m_outputOption[editor.CurrentEditingGroup]; var newOption = (OutputOption)EditorGUILayout.EnumPopup("Output Option", opt); if (newOption != opt) { using (new RecordUndoScope("Change Output Option", node, true)){ m_outputOption[editor.CurrentEditingGroup] = (int)newOption; onValueChanged(); } } using (new EditorGUI.DisabledScope(opt == OutputOption.BuildInCacheDirectory)) { var newDirPath = editor.DrawFolderSelector("Output Directory", "Select Output Folder", m_outputDir[editor.CurrentEditingGroup], Application.dataPath + "/../", (string folderSelected) => { var projectPath = Directory.GetParent(Application.dataPath).ToString(); if (projectPath == folderSelected) { folderSelected = string.Empty; } else { var index = folderSelected.IndexOf(projectPath); if (index >= 0) { folderSelected = folderSelected.Substring(projectPath.Length + index); if (folderSelected.IndexOf('/') == 0) { folderSelected = folderSelected.Substring(1); } } } return(folderSelected); } ); if (newDirPath != m_outputDir[editor.CurrentEditingGroup]) { using (new RecordUndoScope("Change Output Directory", node, true)){ m_outputDir[editor.CurrentEditingGroup] = newDirPath; onValueChanged(); } } if (opt == OutputOption.ErrorIfNoOutputDirectoryFound && !string.IsNullOrEmpty(m_outputDir [editor.CurrentEditingGroup]) && !Directory.Exists(m_outputDir [editor.CurrentEditingGroup])) { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField(m_outputDir[editor.CurrentEditingGroup] + " does not exist."); if (GUILayout.Button("Create directory")) { Directory.CreateDirectory(m_outputDir[editor.CurrentEditingGroup]); } } EditorGUILayout.Space(); string parentDir = Path.GetDirectoryName(m_outputDir[editor.CurrentEditingGroup]); if (Directory.Exists(parentDir)) { EditorGUILayout.LabelField("Available Directories:"); string[] dirs = Directory.GetDirectories(parentDir); foreach (string s in dirs) { EditorGUILayout.LabelField(s); } } EditorGUILayout.Space(); } var outputDir = PrepareOutputDirectory(BuildTargetUtility.GroupToTarget(editor.CurrentEditingGroup), node.Data, false, false); using (new EditorGUI.DisabledScope(!Directory.Exists(outputDir))) { using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); #if UNITY_EDITOR_OSX string buttonName = "Reveal in Finder"; #else string buttonName = "Show in Explorer"; #endif if (GUILayout.Button(buttonName)) { EditorUtility.RevealInFinder(outputDir); } } } } int bundleOptions = m_enabledBundleOptions[editor.CurrentEditingGroup]; bool isDisableWriteTypeTreeEnabled = 0 < (bundleOptions & (int)BuildAssetBundleOptions.DisableWriteTypeTree); bool isIgnoreTypeTreeChangesEnabled = 0 < (bundleOptions & (int)BuildAssetBundleOptions.IgnoreTypeTreeChanges); // buildOptions are validated during loading. Two flags should not be true at the same time. UnityEngine.Assertions.Assert.IsFalse(isDisableWriteTypeTreeEnabled && isIgnoreTypeTreeChangesEnabled); bool isSomethingDisabled = isDisableWriteTypeTreeEnabled || isIgnoreTypeTreeChangesEnabled; foreach (var option in Model.Settings.BundleOptionSettings) { // contains keyword == enabled. if not, disabled. bool isEnabled = (bundleOptions & (int)option.option) != 0; bool isToggleDisabled = (option.option == BuildAssetBundleOptions.DisableWriteTypeTree && isIgnoreTypeTreeChangesEnabled) || (option.option == BuildAssetBundleOptions.IgnoreTypeTreeChanges && isDisableWriteTypeTreeEnabled); using (new EditorGUI.DisabledScope(isToggleDisabled)) { var result = EditorGUILayout.ToggleLeft(option.description, isEnabled); if (result != isEnabled) { using (new RecordUndoScope("Change Bundle Options", node, true)){ bundleOptions = (result) ? ((int)option.option | bundleOptions) : (((~(int)option.option)) & bundleOptions); m_enabledBundleOptions[editor.CurrentEditingGroup] = bundleOptions; onValueChanged(); } } } } if (isSomethingDisabled) { EditorGUILayout.HelpBox("'Disable Write Type Tree' and 'Ignore Type Tree Changes' can not be used together.", MessageType.Info); } } } }
/** * Build from commandline - entrypoint. */ public static void BuildFromCommandline() { try { var arguments = new List <string>(System.Environment.GetCommandLineArgs()); Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None); Application.SetStackTraceLogType(LogType.Error, StackTraceLogType.None); Application.SetStackTraceLogType(LogType.Warning, StackTraceLogType.None); BuildTarget target = EditorUserBuildSettings.activeBuildTarget; int targetIndex = arguments.FindIndex(a => a == "-target"); if (targetIndex >= 0) { var targetStr = arguments[targetIndex + 1]; LogUtility.Logger.Log("Target specified:" + targetStr); var newTarget = BuildTargetUtility.BuildTargetFromString(arguments[targetIndex + 1]); if (!BuildTargetUtility.IsBuildTargetSupported(newTarget)) { throw new AssetBundleGraphException(newTarget + " is not supported to build with this Unity. Please install platform support with installer(s)."); } if (newTarget != target) { #if UNITY_5_6 || UNITY_5_6_OR_NEWER EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetUtility.TargetToGroup(newTarget), newTarget); #else EditorUserBuildSettings.SwitchActiveBuildTarget(newTarget); #endif target = newTarget; } } int graphIndex = arguments.FindIndex(a => a == "-graph"); int collectionIndex = arguments.FindIndex(a => a == "-collection"); if (graphIndex >= 0 && collectionIndex >= 0) { LogUtility.Logger.Log("-graph and -collection can not be used at once. Aborting..."); return; } Model.ConfigGraph graph = null; if (graphIndex >= 0) { var graphPath = arguments[graphIndex + 1]; LogUtility.Logger.Log("Graph path:" + graphPath); graph = AssetDatabase.LoadAssetAtPath <Model.ConfigGraph>(graphPath); LogUtility.Logger.Log("AssetReference bundle building for:" + BuildTargetUtility.TargetToHumaneString(target)); if (graph == null) { LogUtility.Logger.Log("Graph data not found. To specify graph to execute, use -graph [path]. Aborting..."); return; } var result = AssetBundleGraphUtility.ExecuteGraph(target, graph); if (result.IsAnyIssueFound) { LogUtility.Logger.Log("Building asset bundles terminated because of following errors. Please fix issues by opening editor."); foreach (var e in result.Issues) { LogUtility.Logger.LogError(LogUtility.kTag, e.reason); } } } if (collectionIndex >= 0) { var collectionName = arguments[collectionIndex + 1]; LogUtility.Logger.Log("Collection Name:" + collectionName); LogUtility.Logger.Log("AssetReference bundle building for:" + BuildTargetUtility.TargetToHumaneString(target)); if (collectionName == null) { LogUtility.Logger.Log("Collection name not specified. To specify collection to execute, use -collection [name]. Aborting..."); return; } BatchBuildConfig.GraphCollection c = BatchBuildConfig.GetConfig().Find(collectionName); if (c == null) { LogUtility.Logger.Log("Collection not found. Please open project and configure graph collection. Aborting..."); return; } var result = AssetBundleGraphUtility.ExecuteGraphCollection(target, c); foreach (var r in result) { if (r.IsAnyIssueFound) { foreach (var e in r.Issues) { LogUtility.Logger.LogError(LogUtility.kTag, r.Graph.name + ":" + e.reason); } } } } } catch (Exception e) { LogUtility.Logger.LogError(LogUtility.kTag, e); LogUtility.Logger.LogError(LogUtility.kTag, "Building asset bundles terminated due to unexpected error."); } finally { LogUtility.Logger.Log("End of build."); } }
public void SetupPlatformButtons() { SetupSupportedBuildTargets(); var buttons = new List <PlatformButton>(); Dictionary <BuildTargetGroup, string> icons = new Dictionary <BuildTargetGroup, string> { { BuildTargetGroup.Android, "BuildSettings.Android.Small" }, { BuildTargetGroup.iOS, "BuildSettings.iPhone.Small" }, { BuildTargetGroup.PS4, "BuildSettings.PS4.Small" }, { BuildTargetGroup.PSM, "BuildSettings.PSM.Small" }, { BuildTargetGroup.PSP2, "BuildSettings.PSP2.Small" }, { BuildTargetGroup.SamsungTV, "BuildSettings.Android.Small" }, { BuildTargetGroup.Standalone, "BuildSettings.Standalone.Small" }, { BuildTargetGroup.Tizen, "BuildSettings.Tizen.Small" }, { BuildTargetGroup.tvOS, "BuildSettings.tvOS.Small" }, { BuildTargetGroup.Unknown, "BuildSettings.Standalone.Small" }, { BuildTargetGroup.WebGL, "BuildSettings.WebGL.Small" }, { BuildTargetGroup.WiiU, "BuildSettings.WiiU.Small" }, { BuildTargetGroup.WSA, "BuildSettings.WP8.Small" }, { BuildTargetGroup.XboxOne, "BuildSettings.XboxOne.Small" } #if !UNITY_5_5_OR_NEWER , { BuildTargetGroup.XBOX360, "BuildSettings.Xbox360.Small" }, { BuildTargetGroup.Nintendo3DS, "BuildSettings.N3DS.Small" }, { BuildTargetGroup.PS3, "BuildSettings.PS3.Small" } #endif #if UNITY_5_5_OR_NEWER , { BuildTargetGroup.N3DS, "BuildSettings.N3DS.Small" } #endif #if UNITY_5_6 || UNITY_5_6_OR_NEWER , { BuildTargetGroup.Facebook, "BuildSettings.Facebook.Small" }, { BuildTargetGroup.Switch, "BuildSettings.Switch.Small" } #endif }; buttons.Add(new PlatformButton(new GUIContent("Default", "Default settings"), BuildTargetGroup.Unknown)); foreach (var g in supportedBuildTargetGroups) { buttons.Add(new PlatformButton(new GUIContent(GetPlatformIcon(icons[g]), BuildTargetUtility.GroupToHumaneString(g)), g)); } this.platformButtons = buttons.ToArray(); }
public void CopyDefaultValueTo(BuildTarget t) { CopyDefaultValueTo(BuildTargetUtility.TargetToGroup(t)); }
private void OverwriteImportSettings(TextureImporter importer) { var reference = referenceImporter as TextureImporter; UnityEngine.Assertions.Assert.IsNotNull(reference); importer.textureType = reference.textureType; TextureImporterSettings settings = new TextureImporterSettings(); reference.ReadTextureSettings(settings); importer.SetTextureSettings(settings); // some unity version do not properly copy properties via TextureSettings, // so also perform manual copy importer.anisoLevel = reference.anisoLevel; importer.borderMipmap = reference.borderMipmap; importer.compressionQuality = reference.compressionQuality; importer.convertToNormalmap = reference.convertToNormalmap; importer.fadeout = reference.fadeout; importer.filterMode = reference.filterMode; importer.generateCubemap = reference.generateCubemap; importer.heightmapScale = reference.heightmapScale; importer.isReadable = reference.isReadable; importer.maxTextureSize = reference.maxTextureSize; importer.mipMapBias = reference.mipMapBias; importer.mipmapEnabled = reference.mipmapEnabled; importer.mipmapFadeDistanceEnd = reference.mipmapFadeDistanceEnd; importer.mipmapFadeDistanceStart = reference.mipmapFadeDistanceStart; importer.mipmapFilter = reference.mipmapFilter; importer.normalmapFilter = reference.normalmapFilter; importer.npotScale = reference.npotScale; importer.spriteBorder = reference.spriteBorder; importer.spriteImportMode = reference.spriteImportMode; importer.spritePackingTag = reference.spritePackingTag; importer.spritePivot = reference.spritePivot; importer.spritePixelsPerUnit = reference.spritePixelsPerUnit; importer.spritesheet = reference.spritesheet; importer.wrapMode = reference.wrapMode; /* read only */ // importer.qualifiesForSpritePacking #if !UNITY_5_5_OR_NEWER // obsolete features importer.generateMipsInLinearSpace = reference.generateMipsInLinearSpace; importer.grayscaleToAlpha = reference.grayscaleToAlpha; importer.lightmap = reference.lightmap; importer.linearTexture = reference.linearTexture; importer.normalmap = reference.normalmap; importer.textureFormat = reference.textureFormat; foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups) { var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g, BuildTargetUtility.PlatformNameType.TextureImporter); int maxTextureSize; TextureImporterFormat format; int compressionQuality; if (reference.GetPlatformTextureSettings(platformName, out maxTextureSize, out format, out compressionQuality)) { importer.SetPlatformTextureSettings(platformName, maxTextureSize, format, compressionQuality, false); } else { importer.ClearPlatformTextureSettings(platformName); } } #else importer.allowAlphaSplitting = reference.allowAlphaSplitting; importer.alphaIsTransparency = reference.alphaIsTransparency; importer.textureShape = reference.textureShape; importer.alphaSource = reference.alphaSource; importer.sRGBTexture = reference.sRGBTexture; importer.textureCompression = reference.textureCompression; importer.crunchedCompression = reference.crunchedCompression; foreach (var g in NodeGUIUtility.SupportedBuildTargetGroups) { var platformName = BuildTargetUtility.TargetToAssetBundlePlatformName(g, BuildTargetUtility.PlatformNameType.TextureImporter); var impSet = reference.GetPlatformTextureSettings(platformName); importer.SetPlatformTextureSettings(impSet); } #endif #if UNITY_2017_1_OR_NEWER importer.alphaTestReferenceValue = reference.alphaTestReferenceValue; importer.mipMapsPreserveCoverage = reference.mipMapsPreserveCoverage; importer.wrapModeU = reference.wrapModeU; importer.wrapModeV = reference.wrapModeV; importer.wrapModeW = reference.wrapModeW; #endif }
public T Get <T>(BuildTarget t) { return(Get <T>(BuildTargetUtility.TargetToGroup(t))); }