public override void OnEnable() { base.OnEnable(); m_ForceToMono = serializedObject.FindProperty("m_ForceToMono"); m_Normalize = serializedObject.FindProperty("m_Normalize"); m_PreloadAudioData = serializedObject.FindProperty("m_PreloadAudioData"); m_Ambisonic = serializedObject.FindProperty("m_Ambisonic"); m_LoadInBackground = serializedObject.FindProperty("m_LoadInBackground"); m_OrigSize = serializedObject.FindProperty("m_PreviewData.m_OrigSize"); m_CompSize = serializedObject.FindProperty("m_PreviewData.m_CompSize"); m_DefaultSampleSettings = serializedObject.FindProperty("m_DefaultSettings"); m_SelectionContainsTrackerFile = false; foreach (AudioImporter importer in GetAllAudioImporterTargets()) { string assetPath = importer.assetPath; string ext = FileUtil.GetPathExtension(assetPath).ToLowerInvariant(); if (ext == "mod" || ext == "it" || ext == "s3m" || ext == "xm") { m_SelectionContainsTrackerFile = true; break; } } m_DirtyCount = new List <int>(targets.Length); for (int i = 0; i < targets.Length; i++) { m_DirtyCount.Add(EditorUtility.GetDirtyCount(targets[i])); } }
private static bool ValidPathForTextureAsset(string path) { string lower = FileUtil.GetPathExtension(path).ToLower(); if (!(lower == "jpg") && !(lower == "jpeg") && (!(lower == "tif") && !(lower == "tiff")) && (!(lower == "tga") && !(lower == "gif") && (!(lower == "png") && !(lower == "psd"))) && (!(lower == "bmp") && !(lower == "iff") && (!(lower == "pict") && !(lower == "pic")) && (!(lower == "pct") && !(lower == "exr")))) { return(lower == "hdr"); } return(true); }
private bool IsUsableOnLinux(PluginImporter imp) { if (!imp.isNativePlugin) { return(true); } string ext = FileUtil.GetPathExtension(imp.assetPath).ToLower(); return(ext == "so" || IsCppPluginFile(imp.assetPath)); }
public override void OnInspectorGUI() { serializedObject.Update(); bool selectionContainsTrackerFile = false; foreach (AudioImporter importer in GetAllAudioImporterTargets()) { string assetPath = importer.assetPath; string ext = FileUtil.GetPathExtension(assetPath).ToLowerInvariant(); if (ext == "mod" || ext == "it" || ext == "s3m" || ext == "xm") { selectionContainsTrackerFile = true; break; } } OnAudioImporterGUI(selectionContainsTrackerFile); int origSize = 0, compSize = 0; foreach (AudioImporter importer in GetAllAudioImporterTargets()) { origSize += importer.origSize; compSize += importer.compSize; } GUILayout.Space(10); EditorGUILayout.HelpBox("Original Size: \t" + EditorUtility.FormatBytes(origSize) + "\nImported Size: \t" + EditorUtility.FormatBytes(compSize) + "\n" + "Ratio: \t\t" + (100.0f * (float)compSize / (float)origSize).ToString("0.00", CultureInfo.InvariantCulture.NumberFormat) + "%", MessageType.Info); if (CurrentPlatformHasAutoTranslatedCompression()) { GUILayout.Space(10); EditorGUILayout.HelpBox("The selection contains different compression formats to the default settings for the current build platform.", MessageType.Info); } if (CurrentSelectionContainsHardwareSounds()) { GUILayout.Space(10); EditorGUILayout.HelpBox("The selection contains sounds that are decompressed in hardware. Advanced mixing is not available for these sounds.", MessageType.Info); } serializedObject.ApplyModifiedProperties(); ApplyRevertGUI(); }
private static bool ValidPathForTextureAsset(string path) { string ext = FileUtil.GetPathExtension(path).ToLower(); return (ext == "jpg" || ext == "jpeg" || ext == "tif" || ext == "tiff" || ext == "tga" || ext == "gif" || ext == "png" || ext == "psd" || ext == "bmp" || ext == "iff" || ext == "pict" || ext == "pic" || ext == "pct" || ext == "exr" || ext == "hdr"); }
public override void OnInspectorGUI() { this.serializedObject.UpdateIfDirtyOrScript(); bool selectionContainsTrackerFile = false; foreach (AssetImporter audioImporterTarget in this.GetAllAudioImporterTargets()) { string lowerInvariant = FileUtil.GetPathExtension(audioImporterTarget.assetPath).ToLowerInvariant(); if (lowerInvariant == "mod" || lowerInvariant == "it" || (lowerInvariant == "s3m" || lowerInvariant == "xm")) { selectionContainsTrackerFile = true; break; } } this.OnAudioImporterGUI(selectionContainsTrackerFile); int bytes1 = 0; int bytes2 = 0; foreach (AudioImporter audioImporterTarget in this.GetAllAudioImporterTargets()) { bytes1 += audioImporterTarget.origSize; bytes2 += audioImporterTarget.compSize; } GUILayout.Space(10f); EditorGUILayout.HelpBox("Original Size: \t" + EditorUtility.FormatBytes(bytes1) + "\nImported Size: \t" + EditorUtility.FormatBytes(bytes2) + "\nRatio: \t\t" + (100f * (float)bytes2 / (float)bytes1).ToString("0.00") + "%", MessageType.Info); if (this.CurrentPlatformHasAutoTranslatedCompression()) { GUILayout.Space(10f); EditorGUILayout.HelpBox("The selection contains different compression formats to the default settings for the current build platform.", MessageType.Info); } if (this.CurrentSelectionContainsHardwareSounds()) { GUILayout.Space(10f); EditorGUILayout.HelpBox("The selection contains sounds that are decompressed in hardware. Advanced mixing is not available for these sounds.", MessageType.Info); } this.ApplyRevertGUI(); }
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); }