Class BatchSoundEffectImporter
Builds UnityAudioPlayerClipDefinition assets in batch from validated wizard input,
with rollback on failure (mirrors GameSettingCreator / ModalCreator). The
BatchSoundEffectImportWindow only collects input and renders results; all inference,
validation, path generation, duplicate detection and asset creation live here so they can be unit
tested without the window.
Inheritance
BatchSoundEffectImporter
Assembly: Serenity.UnityAudioPlayer.Infrastructure.Editor.dll
Syntax
public static class BatchSoundEffectImporter
Fields
AudioExtensions
File extensions Unity can import as an UnityEngine.AudioClip (matches the project's
UnityAudioPlayerClipDefinitionPostprocessor list).
Declaration
public static readonly IReadOnlyList<string> AudioExtensions
Field Value
Methods
BuildAssetPath(string, string)
Project-relative asset path for an item in a destination folder (no uniqueness applied).
Declaration
public static string BuildAssetPath(string folderPath, string assetName)
Parameters
Returns
CollectExistingClipIds()
Declaration
public static HashSet<string> CollectExistingClipIds()
Returns
Creates a clip definition asset per included item in a single batch, rolling back every created
asset if any step throws. Re-validates first so the creator is safe to call independently of the
window's live validation.
Declaration
public static BatchSoundEffectImporter.Result Create(BatchSoundEffectImporter.Input input)
Parameters
Returns
FileNameSafe(string)
Declaration
public static string FileNameSafe(string name)
Parameters
| Type |
Name |
Description |
| string |
name |
|
Returns
FindDuplicateAssetNames(IEnumerable<Item>)
Returns the file names that resolve to the same asset path among the included items.
Declaration
public static List<string> FindDuplicateAssetNames(IEnumerable<BatchSoundEffectImporter.Item> items)
Parameters
Returns
FindDuplicateIds(IEnumerable<Item>)
Returns the ids that appear more than once among the included items (ordinal).
Declaration
public static List<string> FindDuplicateIds(IEnumerable<BatchSoundEffectImporter.Item> items)
Parameters
Returns
ImportExternalAudioFile(string, string, out string)
Copies an audio file from anywhere on disk into destinationFolder (a project
folder), imports it, and returns the resulting UnityEngine.AudioClip. Files already inside the
project are loaded in place. Returns null with error on failure.
Declaration
public static AudioClip ImportExternalAudioFile(string osPath, string destinationFolder, out string error)
Parameters
Returns
| Type |
Description |
| AudioClip |
|
IsAudioFile(string)
True when path ends with a known importable audio extension.
Declaration
public static bool IsAudioFile(string path)
Parameters
| Type |
Name |
Description |
| string |
path |
|
Returns
ItemFromClip(AudioClip)
Builds an item with inferred defaults for an already-imported project clip.
Declaration
public static BatchSoundEffectImporter.Item ItemFromClip(AudioClip clip)
Parameters
| Type |
Name |
Description |
| AudioClip |
clip |
|
Returns
SuggestAssetName(string)
Suggests an asset file name from a file name (the original name without extension).
Declaration
public static string SuggestAssetName(string fileNameOrPath)
Parameters
| Type |
Name |
Description |
| string |
fileNameOrPath |
|
Returns
SuggestId(string)
Suggests a runtime id from a file name: lower-cased, spaces and invalid characters collapsed to
single underscores, trimmed. e.g. "Sword Hit 01.wav" -> "sword_hit_01".
Declaration
public static string SuggestId(string fileNameOrPath)
Parameters
| Type |
Name |
Description |
| string |
fileNameOrPath |
|
Returns
ToProjectRelativePath(string)
Returns the project-relative ("Assets/…") path for an absolute OS path that lives inside this
project, or null when the path is outside the project.
Declaration
public static string ToProjectRelativePath(string osPath)
Parameters
| Type |
Name |
Description |
| string |
osPath |
|
Returns
Convenience overload that collects existing clip ids from the project.
Declaration
public static string Validate(BatchSoundEffectImporter.Input input)
Parameters
Returns
Full validation including destination folder, per-item rules, in-batch duplicate ids/names and
collision with existing clip ids. existingClipIds is injected so the rules are
testable without the AssetDatabase; the parameterless overload collects them from the project.
Declaration
public static string Validate(BatchSoundEffectImporter.Input input, HashSet<string> existingClipIds)
Parameters
Returns
ValidateItem(Item)
Validates a single included item's identity and clip assignment. Returns null when valid.
Declaration
public static string ValidateItem(BatchSoundEffectImporter.Item item)
Parameters
Returns