private AudioImporterInspector.MultiValueStatus GetMultiValueStatus(BuildTargetGroup platform) { AudioImporterInspector.MultiValueStatus multiValueStatus; multiValueStatus.multiLoadType = false; multiValueStatus.multiSampleRateSetting = false; multiValueStatus.multiSampleRateOverride = false; multiValueStatus.multiCompressionFormat = false; multiValueStatus.multiQuality = false; multiValueStatus.multiConversionMode = false; if (this.GetAllAudioImporterTargets().Any <AudioImporter>()) { AudioImporter audioImporter1 = this.GetAllAudioImporterTargets().First <AudioImporter>(); AudioImporterSampleSettings importerSampleSettings1 = platform != BuildTargetGroup.Unknown ? audioImporter1.Internal_GetOverrideSampleSettings(platform) : audioImporter1.defaultSampleSettings; IEnumerable <AudioImporter> audioImporterTargets = this.GetAllAudioImporterTargets(); AudioImporter[] audioImporterArray = new AudioImporter[1] { audioImporter1 }; foreach (AudioImporter audioImporter2 in audioImporterTargets.Except <AudioImporter>((IEnumerable <AudioImporter>)audioImporterArray)) { AudioImporterSampleSettings importerSampleSettings2 = platform != BuildTargetGroup.Unknown ? audioImporter2.Internal_GetOverrideSampleSettings(platform) : audioImporter2.defaultSampleSettings; multiValueStatus.multiLoadType |= importerSampleSettings1.loadType != importerSampleSettings2.loadType; multiValueStatus.multiSampleRateSetting |= importerSampleSettings1.sampleRateSetting != importerSampleSettings2.sampleRateSetting; multiValueStatus.multiSampleRateOverride |= (int)importerSampleSettings1.sampleRateOverride != (int)importerSampleSettings2.sampleRateOverride; multiValueStatus.multiCompressionFormat |= importerSampleSettings1.compressionFormat != importerSampleSettings2.compressionFormat; multiValueStatus.multiQuality |= (double)importerSampleSettings1.quality != (double)importerSampleSettings2.quality; multiValueStatus.multiConversionMode |= importerSampleSettings1.conversionMode != importerSampleSettings2.conversionMode; } } return(multiValueStatus); }
public bool CurrentSelectionContainsHardwareSounds() { BuildTargetGroup buildTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget); IEnumerator <AudioImporter> enumerator = this.GetAllAudioImporterTargets().GetEnumerator(); try { while (enumerator.MoveNext()) { AudioImporterSampleSettings settings = enumerator.Current.Internal_GetOverrideSampleSettings(buildTargetGroup); if (this.IsHardwareSound(settings.compressionFormat)) { return(true); } } } finally { if (enumerator == null) { } enumerator.Dispose(); } return(false); }
public bool SetOverrideSampleSettings(string platform, AudioImporterSampleSettings settings) { BuildTargetGroup buildTargetGroupByName = BuildPipeline.GetBuildTargetGroupByName(platform); if (buildTargetGroupByName == BuildTargetGroup.Unknown) { Debug.LogError("Unknown platform passed to AudioImporter.SetOverrideSampleSettings (" + platform + "), please use one of 'Web', 'Standalone', 'iOS', 'Android', 'WebGL', 'PS3', 'PS4', 'PSP2', 'PSM', 'XBox360', 'XboxOne', 'WP8', 'WSA' or 'BlackBerry'"); return false; } return this.Internal_SetOverrideSampleSettings(buildTargetGroupByName, settings); }
public bool SetOverrideSampleSettings(string platform, AudioImporterSampleSettings settings) { BuildTargetGroup buildTargetGroupByName = BuildPipeline.GetBuildTargetGroupByName(platform); if (buildTargetGroupByName == BuildTargetGroup.Unknown) { Debug.LogError("Unknown platform passed to AudioImporter.SetOverrideSampleSettings (" + platform + "), please use one of 'Web', 'Standalone', 'iOS', 'Android', 'WebGL', 'PS3', 'PS4', 'PSP2', 'PSM', 'XBox360', 'XboxOne', 'WP8', 'WSA' or 'BlackBerry'"); return(false); } return(this.Internal_SetOverrideSampleSettings(buildTargetGroupByName, settings)); }
public bool SetOverrideSampleSettings(string platform, AudioImporterSampleSettings settings) { BuildTargetGroup platformGroup = BuildPipeline.GetBuildTargetGroupByName(platform); if (platformGroup == BuildTargetGroup.Unknown) { Debug.LogError("Unknown platform passed to AudioImporter.SetOverrideSampleSettings (" + platform + "), please use one of " + "'Web', 'Standalone', 'iOS', 'Android', 'WebGL', 'PS4', 'XboxOne' or 'WSA'"); return(false); } return(Internal_SetOverrideSampleSettings(platformGroup, settings)); }
public bool CurrentSelectionContainsHardwareSounds() { BuildTargetGroup buildTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget); foreach (AudioImporter importer in this.GetAllAudioImporterTargets()) { AudioImporterSampleSettings settings = importer.Internal_GetOverrideSampleSettings(buildTargetGroup); if (this.IsHardwareSound(settings.compressionFormat)) { return(true); } } return(false); }
public bool SetOverrideSampleSettings(string platform, AudioImporterSampleSettings settings) { BuildTargetGroup buildTargetGroupByName = BuildPipeline.GetBuildTargetGroupByName(platform); bool result; if (buildTargetGroupByName == BuildTargetGroup.Unknown) { Debug.LogError("Unknown platform passed to AudioImporter.SetOverrideSampleSettings (" + platform + "), please use one of 'Web', 'Standalone', 'iOS', 'Android', 'WebGL', 'PS4', 'PSP2', 'XboxOne' or 'WSA'"); result = false; } else { result = this.Internal_SetOverrideSampleSettings(buildTargetGroupByName, settings); } return(result); }
public bool CurrentPlatformHasAutoTranslatedCompression() { BuildTargetGroup targetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget); foreach (AudioImporter importer in GetAllAudioImporterTargets()) { AudioCompressionFormat defaultCompressionFormat = importer.defaultSampleSettings.compressionFormat; // Because we only want to query if the importer does not have an override. if (!importer.Internal_ContainsSampleSettingsOverride(targetGroup)) { AudioImporterSampleSettings overrideSettings = importer.Internal_GetOverrideSampleSettings(targetGroup); AudioCompressionFormat overrideCompressionFormat = overrideSettings.compressionFormat; // If we dont have an override, but the translated compression format is different, // this means we have audio translate happening. if (defaultCompressionFormat != overrideCompressionFormat) { return(true); } } } return(false); }
internal extern bool Internal_SetOverrideSampleSettings(BuildTargetGroup platformGroup, AudioImporterSampleSettings settings);
public bool SetOverrideSampleSettings(string platform, AudioImporterSampleSettings settings) { return(ValidatePlatform(platform, "AudioImporter.SetOverrideSampleSettings", out BuildTargetGroup platformGroup) ? Internal_SetOverrideSampleSettings(platformGroup, settings) : false); }
internal extern bool Internal_SetOverrideSampleSettings(BuildTargetGroup platformGroup, AudioImporterSampleSettings settings);
public void OnPreprocessAudio() { if (EasyVoiceSettings.instance == null) return; if (EasyVoiceSettings.instance.data == null) return; if (EasyVoiceClipCreator.lastCreatedAssetFileNames == null) return; // If user hasn't specified we need to apply custom settings, then don't bother touching the asset if (!EasyVoiceSettings.instance.audioImportSettings.applyCustomSettings) return; string ourAssetPath = assetPath; if (!ourAssetPath.StartsWith("Assets/")) return; //ourAssetPath = ourAssetPath.Substring(6); #if DEBUG_MESSAGES Debug.Log("Importing audio asset at " + ourAssetPath); #endif if (EasyVoiceClipCreator.lastCreatedAssetFileNames.Contains(ourAssetPath)) { #if DEBUG_MESSAGES Debug.Log("Matched a created asset!"); #endif AudioImporter audioImporter = (AudioImporter)assetImporter; // Setup generic importer settings audioImporter.forceToMono = EasyVoiceSettings.instance.audioImportSettings.forceToMono; audioImporter.loadInBackground = EasyVoiceSettings.instance.audioImportSettings.loadInBackground; audioImporter.preloadAudioData = EasyVoiceSettings.instance.audioImportSettings.preloadAudioData; // Setup new (default) setting for the importer and convert from out stored values AudioImporterSampleSettings settings = new AudioImporterSampleSettings(); settings.loadType = LoadType(EasyVoiceSettings.instance.audioImportSettings.loadType); settings.compressionFormat = CompressionFormat(EasyVoiceSettings.instance.audioImportSettings.compressionFormat); settings.quality = EasyVoiceSettings.instance.audioImportSettings.quality; settings.sampleRateSetting = SampleRate(EasyVoiceSettings.instance.audioImportSettings.sampleRateSetting); settings.sampleRateOverride = EasyVoiceSettings.instance.audioImportSettings.overrideSampleRate; // Apply the new (default) settings to the importer audioImporter.defaultSampleSettings = settings; // We used to do this: // audioImporter.threeD = EasyVoiceSettings.instance.importClips3D; // audioImporter.format = AudioImporterFormatValue(EasyVoiceSettings.instance.importClipsFormat); // audioImporter.loadType = AudioImporterLoadTypeValue(EasyVoiceSettings.instance.importClipsLoadType); //EasyVoiceSettings.instance.data.lastCreatedAssetFileNames.Remove(ourAssetPath); -- CreateFiles() will do this, we are forcing immediate import anyway } #if DEBUG_MESSAGES else { foreach (string lastCreatedAssetFileName in EasyVoiceClipCreator.lastCreatedAssetFileNames) { Debug.Log("Didn't match " + lastCreatedAssetFileName); } } #endif }
private bool SyncSettingsToBackend() { BuildPlayerWindow.BuildPlatform[] array = BuildPlayerWindow.GetValidPlatforms().ToArray(); foreach (AudioImporter audioImporterTarget in this.GetAllAudioImporterTargets()) { AudioImporterSampleSettings defaultSampleSettings = audioImporterTarget.defaultSampleSettings; if (this.m_DefaultSampleSettings.loadTypeChanged) { defaultSampleSettings.loadType = this.m_DefaultSampleSettings.settings.loadType; } if (this.m_DefaultSampleSettings.sampleRateSettingChanged) { defaultSampleSettings.sampleRateSetting = this.m_DefaultSampleSettings.settings.sampleRateSetting; } if (this.m_DefaultSampleSettings.sampleRateOverrideChanged) { defaultSampleSettings.sampleRateOverride = this.m_DefaultSampleSettings.settings.sampleRateOverride; } if (this.m_DefaultSampleSettings.compressionFormatChanged) { defaultSampleSettings.compressionFormat = this.m_DefaultSampleSettings.settings.compressionFormat; } if (this.m_DefaultSampleSettings.qualityChanged) { defaultSampleSettings.quality = this.m_DefaultSampleSettings.settings.quality; } if (this.m_DefaultSampleSettings.conversionModeChanged) { defaultSampleSettings.conversionMode = this.m_DefaultSampleSettings.settings.conversionMode; } audioImporterTarget.defaultSampleSettings = defaultSampleSettings; foreach (BuildPlayerWindow.BuildPlatform buildPlatform in array) { BuildTargetGroup targetGroup = buildPlatform.targetGroup; if (this.m_SampleSettingOverrides.ContainsKey(targetGroup)) { AudioImporterInspector.SampleSettingProperties sampleSettingOverride = this.m_SampleSettingOverrides[targetGroup]; if (sampleSettingOverride.overrideIsForced && !sampleSettingOverride.forcedOverrideState) { audioImporterTarget.Internal_ClearSampleSettingOverride(targetGroup); } else if (audioImporterTarget.Internal_ContainsSampleSettingsOverride(targetGroup) || sampleSettingOverride.overrideIsForced && sampleSettingOverride.forcedOverrideState) { AudioImporterSampleSettings overrideSampleSettings = audioImporterTarget.Internal_GetOverrideSampleSettings(targetGroup); if (sampleSettingOverride.loadTypeChanged) { overrideSampleSettings.loadType = sampleSettingOverride.settings.loadType; } if (sampleSettingOverride.sampleRateSettingChanged) { overrideSampleSettings.sampleRateSetting = sampleSettingOverride.settings.sampleRateSetting; } if (sampleSettingOverride.sampleRateOverrideChanged) { overrideSampleSettings.sampleRateOverride = sampleSettingOverride.settings.sampleRateOverride; } if (sampleSettingOverride.compressionFormatChanged) { overrideSampleSettings.compressionFormat = sampleSettingOverride.settings.compressionFormat; } if (sampleSettingOverride.qualityChanged) { overrideSampleSettings.quality = sampleSettingOverride.settings.quality; } if (sampleSettingOverride.conversionModeChanged) { overrideSampleSettings.conversionMode = sampleSettingOverride.settings.conversionMode; } audioImporterTarget.Internal_SetOverrideSampleSettings(targetGroup, overrideSampleSettings); } this.m_SampleSettingOverrides[targetGroup] = sampleSettingOverride; } } } this.m_DefaultSampleSettings.ClearChangedFlags(); foreach (BuildPlayerWindow.BuildPlatform buildPlatform in array) { BuildTargetGroup targetGroup = buildPlatform.targetGroup; if (this.m_SampleSettingOverrides.ContainsKey(targetGroup)) { AudioImporterInspector.SampleSettingProperties sampleSettingOverride = this.m_SampleSettingOverrides[targetGroup]; sampleSettingOverride.ClearChangedFlags(); this.m_SampleSettingOverrides[targetGroup] = sampleSettingOverride; } } return(true); }
private bool SyncSettingsToBackend() { BuildPlatform[] validPlatforms = BuildPlatforms.instance.GetValidPlatforms().ToArray(); foreach (AudioImporter importer in GetAllAudioImporterTargets()) { { AudioImporterSampleSettings importerDefaults = importer.defaultSampleSettings; //Importer default settings if (m_DefaultSampleSettings.loadTypeChanged) { importerDefaults.loadType = m_DefaultSampleSettings.settings.loadType; } if (m_DefaultSampleSettings.sampleRateSettingChanged) { importerDefaults.sampleRateSetting = m_DefaultSampleSettings.settings.sampleRateSetting; } if (m_DefaultSampleSettings.sampleRateOverrideChanged) { importerDefaults.sampleRateOverride = m_DefaultSampleSettings.settings.sampleRateOverride; } if (m_DefaultSampleSettings.compressionFormatChanged) { importerDefaults.compressionFormat = m_DefaultSampleSettings.settings.compressionFormat; } if (m_DefaultSampleSettings.qualityChanged) { importerDefaults.quality = m_DefaultSampleSettings.settings.quality; } if (m_DefaultSampleSettings.conversionModeChanged) { importerDefaults.conversionMode = m_DefaultSampleSettings.settings.conversionMode; } //Set the default settings on the importer after the changes. importer.defaultSampleSettings = importerDefaults; } //Get all the valid platforms, and write changes only for those ones foreach (BuildPlatform platform in validPlatforms) { BuildTargetGroup platformGroup = platform.targetGroup; if (m_SampleSettingOverrides.ContainsKey(platformGroup)) { SampleSettingProperties overrideProperties = m_SampleSettingOverrides[platformGroup]; if (overrideProperties.overrideIsForced && !overrideProperties.forcedOverrideState) { importer.Internal_ClearSampleSettingOverride(platformGroup); } else if (importer.Internal_ContainsSampleSettingsOverride(platformGroup) || (overrideProperties.overrideIsForced && overrideProperties.forcedOverrideState)) { AudioImporterSampleSettings overrideSettings = importer.Internal_GetOverrideSampleSettings(platformGroup); if (overrideProperties.loadTypeChanged) { overrideSettings.loadType = overrideProperties.settings.loadType; } if (overrideProperties.sampleRateSettingChanged) { overrideSettings.sampleRateSetting = overrideProperties.settings.sampleRateSetting; } if (overrideProperties.sampleRateOverrideChanged) { overrideSettings.sampleRateOverride = overrideProperties.settings.sampleRateOverride; } if (overrideProperties.compressionFormatChanged) { overrideSettings.compressionFormat = overrideProperties.settings.compressionFormat; } if (overrideProperties.qualityChanged) { overrideSettings.quality = overrideProperties.settings.quality; } if (overrideProperties.conversionModeChanged) { overrideSettings.conversionMode = overrideProperties.settings.conversionMode; } //Set the default settings on the importer after the changes. importer.Internal_SetOverrideSampleSettings(platformGroup, overrideSettings); } m_SampleSettingOverrides[platformGroup] = overrideProperties; } } } //Now that we are in sync with the backend, we need to clear the changed flags within //the properties m_DefaultSampleSettings.ClearChangedFlags(); foreach (BuildPlatform platform in validPlatforms) { BuildTargetGroup platformGroup = platform.targetGroup; if (m_SampleSettingOverrides.ContainsKey(platformGroup)) { SampleSettingProperties overrideProperties = m_SampleSettingOverrides[platformGroup]; overrideProperties.ClearChangedFlags(); m_SampleSettingOverrides[platformGroup] = overrideProperties; } } return(true); }
private void _DrawClipList() { int minWidth = showFullClipDetails ? 750 : 600; int screenWidth = Mathf.Max(Screen.width, minWidth); int iconSize = lineHeight; GUILayout.BeginArea(new Rect(0f, (showHierarchy || showProperties) ? bottomSplitter.pos + bottomSplitter.thickness : 0f, Screen.width, (showHierarchy || showProperties) ? Screen.height - bottomSplitter.pos - bottomSplitter.thickness - lineHeight * 2 : Screen.height)); // Header Rect headerRect = DrawHeader("AUDIO CLIPS", ref clipSearchString, Screen.width / 4, true); // Column labels Rect columnRect = EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.Width(screenWidth), GUILayout.Height(headerHeight)); headerStyle.alignment = TextAnchor.MiddleCenter; GUILayout.Label(GUIContent.none, GUILayout.Width(iconSize * 2), GUILayout.MaxWidth(iconSize * 2), GUILayout.MinWidth(iconSize * 2), GUILayout.ExpandWidth(false), GUILayout.Height(headerHeight)); string[] categories = { #if UNITY_4 "NAME", "LENGTH", "CHANNELS", "LOAD", "CMPRESN", "3D", // ADVANCED "HRDWARE", "LOOP", "BITRATE", "MONO", #else "NAME", "LENGTH", "CHANNELS", "LOAD", "CMPRESN", // ADVANCED "QUALITY", "SAMPLNG", "BKGRND", "PRE LD", "MONO", #endif }; float[] widthScales = { #if UNITY_4 1.75f, // NAME 0.6f, // LENGTH 0.8f, // CHANNELS 0.7f, // LOAD 0.8f, // CMPRESN 0.4f, // 3D // ADVANCED 0.7f, // HARDWARE 0.4f, // LOOP 0.6f, // BITRATE 0.4f, // MONO #else 1.75f, // NAME 0.6f, // LENGTH 0.65f, // CHANNELS 0.6f, // LOAD 0.6f, // CMPRESN // ADVANCED 0.6f, // QUALITY 0.6f, // SAMPLNG 0.5f, // BKGRND 0.45f, // PRE LD 0.45f, // MONO #endif }; int[] widths = new int[categories.Length]; #if UNITY_4 int advancedStart = 6; #else int advancedStart = 5; #endif float weightSum = 0; for(int catIndex = 0; catIndex < (showFullClipDetails ? categories.Length : advancedStart); ++catIndex) { weightSum += widthScales[catIndex]; } int columnSum = 0; for(int catIndex = 0; catIndex < (showFullClipDetails ? categories.Length : advancedStart); ++catIndex) { int width = (int)(screenWidth * 0.98f * (widthScales[catIndex] / weightSum)); GUI.Label(new Rect(columnRect.x + columnSum, columnRect.y, width, columnRect.height), categories[catIndex], headerStyle); columnSum += width; widths[catIndex] = width; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); // Audio Clips clipScrollPos = EditorGUILayout.BeginScrollView(clipScrollPos); string searchString = clipSearchString.ToLower(); foreach(string folderName in clipItems.Keys) { AudioClipFolder folder = clipItems[folderName]; Rect folderRect = EditorGUILayout.BeginHorizontal(); elementStyle.normal.textColor = UnselectedItemColor; elementStyle.alignment = TextAnchor.MiddleLeft; if(GUILayout.Button(folder.expanded ? expandedIcon : collapsedIcon, elementStyle, GUILayout.Width(iconSize), GUILayout.Height(iconSize))) { folder.expanded = !folder.expanded; EditorPrefs.SetBool(expandedPrefPrefix + folderName, folder.expanded); } GUILayout.Label(folderIcon, elementStyle, GUILayout.Width(iconSize), GUILayout.Height(iconSize)); GUILayout.Label(folderName, elementStyle); EditorGUILayout.EndHorizontal(); if(folder.expanded) { deadItems.Clear(); foreach(TreeItem item in folder.items) { AudioImporter importer = item.Importer; if(importer == null || string.IsNullOrEmpty(item.Path)) { deadItems.Add(item); } else if((string.IsNullOrEmpty(clipSearchString) || item.Name.ToLower().Contains(searchString))) { item.ScrollRect = EditorGUILayout.BeginHorizontal(); item.WindowRect = item.ScrollRect; item.WindowRect.y += bottomSplitter.pos; item.WindowRect.y += headerRect.height; item.WindowRect.y += columnRect.height; item.WindowRect.y += folderRect.height; item.WindowRect.y -= clipScrollPos.y; bool selected = selectedClipItems.Contains(item); if(selected && !lastSelectedHierarchy) { Rect selectionRect = item.ScrollRect; selectionRect.y += 1; selectionRect.height += 1; GUI.Box(selectionRect, "", selectionBoxStyle); } elementStyle.normal.textColor = selected ? Color.white : UnselectedItemColor; // Indent for folder GUILayout.Label(GUIContent.none, GUILayout.Width(iconSize), GUILayout.MaxWidth(iconSize), GUILayout.MinWidth(iconSize), GUILayout.ExpandWidth(false)); // Audition button if(GUILayout.Button(new GUIContent(playIcon, "Plays a preview of this clip."), iconButtonStyle, GUILayout.Width(iconSize), GUILayout.Height(iconSize))) { SECTR_AudioSystem.Audition(item.Clip); selectedClipItem = item; } // Now for all the info bool wasEnabled = GUI.enabled; GUI.enabled &= SECTR_VC.IsEditable(item.Path); int checkSize = 20; int columnIndex = 0; int columnWidth = 0; float rowY = item.ScrollRect.y + 1; columnSum = (int)item.ScrollRect.x; // Editable properties #if UNITY_4 AudioImporterFormat newCompressed = importer.format; AudioImporterLoadType newStream = importer.loadType; bool new3D = importer.threeD; bool newHardware = importer.hardware; bool newLoop = importer.loopable; int bitrate = importer.compressionBitrate; #else AudioCompressionFormat newCompressed = importer.defaultSampleSettings.compressionFormat ; AudioClipLoadType newStream = importer.defaultSampleSettings.loadType; float newQuality = importer.defaultSampleSettings.quality; AudioSampleRateSetting newSampleSetting = importer.defaultSampleSettings.sampleRateSetting; uint newSampleRate = importer.defaultSampleSettings.sampleRateOverride; SampleBehavior oldBehavior = SampleBehavior.PreserveRate; switch(newSampleSetting) { case AudioSampleRateSetting.OptimizeSampleRate: oldBehavior = SampleBehavior.OptimizeRate; break; case AudioSampleRateSetting.OverrideSampleRate: switch(newSampleRate) { case 8000: oldBehavior = SampleBehavior.Force8k; break; case 11025: oldBehavior = SampleBehavior.Force11k; break; case 22050: oldBehavior = SampleBehavior.Force22k; break; case 44100: oldBehavior = SampleBehavior.Force44k; break; case 48000: oldBehavior = SampleBehavior.Force48k; break; case 96000: oldBehavior = SampleBehavior.Force96k; break; case 192000: oldBehavior = SampleBehavior.Force192k; break; } break; } SampleBehavior newBehavior = oldBehavior; bool newBackground = importer.loadInBackground; bool newPreload = importer.preloadAudioData; #endif bool newMono = importer.forceToMono; // Name columnWidth = widths[columnIndex++]; elementStyle.alignment = TextAnchor.MiddleLeft; float shift = iconSize * 2.5f; Rect nameRect = new Rect(columnSum + shift, rowY, columnWidth - shift, item.ScrollRect.height); if(item.Rename) { string focusName = "RenamingItem"; GUI.SetNextControlName(focusName); item.Name = GUI.TextField(nameRect, item.Name); GUI.FocusControl(focusName); } else { GUI.Label(nameRect, item.Name, elementStyle); } elementStyle.alignment = TextAnchor.UpperCenter; columnSum += columnWidth; // Length columnWidth = widths[columnIndex++]; float length = item.Clip.length; string label = "s"; if(length > 60f) { length /= 60f; label = "m"; } EditorGUI.LabelField(new Rect(columnSum, rowY, columnWidth, item.ScrollRect.height), length.ToString("N2") + " " + label, elementStyle); columnSum += columnWidth; // Channels string channels = item.Clip.channels + "ch"; channels += " @ " + (item.Clip.frequency / 1000f) + "k"; columnWidth = widths[columnIndex++]; EditorGUI.LabelField(new Rect(columnSum, rowY, columnWidth, item.ScrollRect.height), channels, elementStyle); columnSum += columnWidth; // Stream vs In Memory columnWidth = widths[columnIndex++]; #if UNITY_4 newStream = (AudioImporterLoadType)EditorGUI.EnumPopup(new Rect(columnSum, rowY, columnWidth * 0.9f, item.ScrollRect.height), newStream); #else newStream = (AudioClipLoadType)EditorGUI.EnumPopup(new Rect(columnSum, rowY, columnWidth * 0.9f, item.ScrollRect.height), newStream); #endif columnSum += columnWidth; // Compressed columnWidth = widths[columnIndex++]; #if UNITY_4 newCompressed = (AudioImporterFormat)EditorGUI.EnumPopup(new Rect(columnSum, rowY, columnWidth * 0.9f, item.ScrollRect.height), newCompressed); #else newCompressed = (AudioCompressionFormat)EditorGUI.EnumPopup(new Rect(columnSum, rowY, columnWidth * 0.9f, item.ScrollRect.height), newCompressed); #endif columnSum += columnWidth; #if UNITY_4 // 3D columnWidth = widths[columnIndex++]; new3D = EditorGUI.Toggle(new Rect(columnSum - checkSize / 2 + columnWidth / 2, rowY, checkSize, item.ScrollRect.height), new3D); columnSum += columnWidth; #endif // Advanced Stuff if(showFullClipDetails) { bool guiWasEnabled = GUI.enabled; #if UNITY_4 // Hardware columnWidth = widths[columnIndex++]; newHardware = EditorGUI.Toggle(new Rect(columnSum - checkSize / 2 + columnWidth / 2, rowY, checkSize, item.ScrollRect.height), newHardware); columnSum += columnWidth; // Loop columnWidth = widths[columnIndex++]; newLoop = EditorGUI.Toggle(new Rect(columnSum - checkSize / 2 + columnWidth / 2, rowY, checkSize, item.ScrollRect.height), newLoop); columnSum += columnWidth; // Bitrate int labelWidth = 40; GUI.enabled &= (newCompressed == AudioImporterFormat.Compressed); columnWidth = widths[columnIndex++]; if(bitrate > 0 ) { GUI.SetNextControlName("Clip Bitrate"); bitrate = EditorGUI.IntField(new Rect(columnSum - labelWidth / 2 + columnWidth / 2, rowY, labelWidth, item.ScrollRect.height), bitrate / 1000, busFieldStyle) * 1000; } else { const int kDefaultBitrate = 156000; GUI.SetNextControlName("Clip Bitrate"); int userBitrate = EditorGUI.IntField(new Rect(columnSum - labelWidth / 2 + columnWidth / 2, rowY, labelWidth, item.ScrollRect.height), kDefaultBitrate / 1000, busFieldStyle) * 1000; if(userBitrate != kDefaultBitrate) { bitrate = userBitrate; } } GUI.enabled = guiWasEnabled; columnSum += columnWidth; #else // Quality bool compressed = (newCompressed == AudioCompressionFormat.Vorbis || newCompressed == AudioCompressionFormat.MP3); int labelWidth = 40; GUI.enabled &= compressed; columnWidth = widths[columnIndex++]; if(newQuality >= 0) { GUI.SetNextControlName("Clip Quality"); newQuality = EditorGUI.FloatField(new Rect(columnSum - labelWidth / 2 + columnWidth / 2, rowY, labelWidth, item.ScrollRect.height), newQuality * 100f, busFieldStyle) / 100f; newQuality = Mathf.Clamp(newQuality, 0f, 1f); } else { const float kDefaultQuality = 0.5f; GUI.SetNextControlName("Clip Quality"); float userQuality = EditorGUI.FloatField(new Rect(columnSum - labelWidth / 2 + columnWidth / 2, rowY, labelWidth, item.ScrollRect.height), kDefaultQuality * 100f, busFieldStyle) / 100f; if(userQuality != kDefaultQuality) { newQuality = Mathf.Clamp(userQuality, 0f, 1f); } } GUI.enabled = true; columnSum += columnWidth; // Sample Settings columnWidth = widths[columnIndex++]; GUI.enabled &= !compressed; newBehavior = (SampleBehavior)EditorGUI.EnumPopup(new Rect(columnSum, rowY, columnWidth * 0.9f, item.ScrollRect.height), oldBehavior); GUI.enabled = guiWasEnabled; columnSum += columnWidth; // Load in background columnWidth = widths[columnIndex++]; newBackground = EditorGUI.Toggle(new Rect(columnSum - checkSize / 2 + columnWidth / 2, rowY, checkSize, item.ScrollRect.height), newBackground); columnSum += columnWidth; // Preload columnWidth = widths[columnIndex++]; newPreload = EditorGUI.Toggle(new Rect(columnSum - checkSize / 2 + columnWidth / 2, rowY, checkSize, item.ScrollRect.height), newPreload); columnSum += columnWidth; #endif // Force Mono columnWidth = widths[columnIndex++]; newMono = EditorGUI.Toggle(new Rect(columnSum - checkSize / 2 + columnWidth / 2, rowY, checkSize, item.ScrollRect.height), newMono); columnSum += columnWidth; } if((newMono != importer.forceToMono) || #if UNITY_4 (newStream != importer.loadType) || (newCompressed != importer.format) || (new3D != importer.threeD) || (newHardware != importer.hardware) || (newLoop != importer.loopable) || (bitrate != importer.compressionBitrate) || #else (newStream != importer.defaultSampleSettings.loadType) || (newCompressed != importer.defaultSampleSettings.compressionFormat) || (newQuality != importer.defaultSampleSettings.quality) || (newBehavior != oldBehavior) || (newBackground != importer.loadInBackground) || (newPreload != importer.preloadAudioData) || #endif (newMono != importer.forceToMono) || changedAudioClip) { #if UNITY_4 importer.loadType = newStream; importer.format = newCompressed; bool changedText = changedAudioClip || bitrate != importer.compressionBitrate; importer.threeD = new3D; importer.hardware = newHardware; importer.loopable = newLoop; importer.compressionBitrate = bitrate; #else bool changedText = changedAudioClip || (importer.defaultSampleSettings.quality != newQuality || importer.defaultSampleSettings.sampleRateOverride != newSampleRate); if(newBehavior != oldBehavior) { switch(newBehavior) { case SampleBehavior.PreserveRate: newSampleSetting = AudioSampleRateSetting.PreserveSampleRate; break; case SampleBehavior.OptimizeRate: newSampleSetting = AudioSampleRateSetting.OptimizeSampleRate; break; case SampleBehavior.Force8k: newSampleSetting = AudioSampleRateSetting.OverrideSampleRate; newSampleRate = 8000; break; case SampleBehavior.Force11k: newSampleSetting = AudioSampleRateSetting.OverrideSampleRate; newSampleRate = 11025; break; case SampleBehavior.Force22k: newSampleSetting = AudioSampleRateSetting.OverrideSampleRate; newSampleRate = 22050; break; case SampleBehavior.Force44k: newSampleSetting = AudioSampleRateSetting.OverrideSampleRate; newSampleRate = 44100; break; case SampleBehavior.Force48k: newSampleSetting = AudioSampleRateSetting.OverrideSampleRate; newSampleRate = 48000; break; case SampleBehavior.Force96k: newSampleSetting = AudioSampleRateSetting.OverrideSampleRate; newSampleRate = 96000; break; case SampleBehavior.Force192k: newSampleSetting = AudioSampleRateSetting.OverrideSampleRate; newSampleRate = 192000; break; } } AudioImporterSampleSettings newSettings = new AudioImporterSampleSettings(); newSettings.loadType = newStream; newSettings.compressionFormat = newCompressed; newSettings.quality = newQuality; newSettings.sampleRateSetting = newSampleSetting; newSettings.sampleRateOverride = newSampleRate; importer.defaultSampleSettings = newSettings; importer.loadInBackground = newBackground; importer.preloadAudioData = newPreload; #endif importer.forceToMono = newMono; changedAudioClip = true; EditorUtility.SetDirty(importer); if(changedAudioClip && string.IsNullOrEmpty(GUI.GetNameOfFocusedControl()) && (!changedText || GUIUtility.keyboardControl == 0)) { AssetDatabase.WriteImportSettingsIfDirty(item.Path); AssetDatabase.Refresh(); changedAudioClip = false; } } GUI.enabled = wasEnabled; EditorGUILayout.EndHorizontal(); displayedClipItems.Add(item); } } int numDeadItems = deadItems.Count; for(int itemIndex = 0; itemIndex < numDeadItems; ++itemIndex) { folder.items.Remove(deadItems[itemIndex]); } } } EditorGUILayout.EndScrollView(); if(Event.current.type == EventType.Repaint) { clipScrollRect = GUILayoutUtility.GetLastRect(); } GUILayout.EndArea(); }