logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class BatchSoundEffectImporter

    Builds UnityAudioPlayerClipDefinition assets in batch from validated wizard input, with rollback on failure. Everything shared with the music-track importer (inference, duplicate detection, validation skeleton, batched creation with rollback, Addressables registration, external file import) lives in Serenity.Global.Infrastructure.Editor.Utils.BatchAudioAssetImportEngine`4; this class supplies only the sound-effect-specific parts via BatchSoundEffectImporter.ImportEngine. The BatchSoundEffectImportWindow only collects input and renders results.

    Inheritance
    object
    BatchSoundEffectImporter
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.AudioPlayer.Infrastructure.Settings.Editor.Builder
    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
    Type Description
    IReadOnlyList<string>

    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
    Type Name Description
    string folderPath
    string assetName
    Returns
    Type Description
    string

    CollectExistingClipIds()

    Returns the ids of every existing UnityAudioPlayerClipDefinition in the project.

    Declaration
    public static HashSet<string> CollectExistingClipIds()
    Returns
    Type Description
    HashSet<string>

    Create(Input)

    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
    Type Name Description
    BatchSoundEffectImporter.Input input
    Returns
    Type Description
    BatchSoundEffectImporter.Result

    FileNameSafe(string)

    Replaces characters illegal in a file name with '_', falling back to a default name. Delegates to FileNameSafe(string, string).

    Declaration
    public static string FileNameSafe(string name)
    Parameters
    Type Name Description
    string name
    Returns
    Type Description
    string

    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
    Type Name Description
    IEnumerable<BatchSoundEffectImporter.Item> items
    Returns
    Type Description
    List<string>

    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
    Type Name Description
    IEnumerable<BatchSoundEffectImporter.Item> items
    Returns
    Type Description
    List<string>

    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
    Type Name Description
    string osPath
    string destinationFolder
    string error
    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
    Type Description
    bool

    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
    Type Description
    BatchSoundEffectImporter.Item

    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
    Type Description
    string

    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
    Type Description
    string

    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
    Type Description
    string

    Validate(Input)

    Convenience overload that collects existing clip ids from the project.

    Declaration
    public static string Validate(BatchSoundEffectImporter.Input input)
    Parameters
    Type Name Description
    BatchSoundEffectImporter.Input input
    Returns
    Type Description
    string

    Validate(Input, HashSet<string>)

    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
    Type Name Description
    BatchSoundEffectImporter.Input input
    HashSet<string> existingClipIds
    Returns
    Type Description
    string

    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
    Type Name Description
    BatchSoundEffectImporter.Item item
    Returns
    Type Description
    string
    In this article
    © 2026 Serenity. All Rights Reserved