logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class SerenityRecipeAssetDatabase

    Thin wrapper over Unity's UnityEditor.AssetDatabase that centralises folder creation, existence/type probing, asset creation, dirtying, and saving for the importer. Write operations are suppressed when DryRun is true, so callers can share one code path for validation, dry runs, and imports.

    Inheritance
    object
    SerenityRecipeAssetDatabase
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    Namespace: Serenity.ProjectRecipe.Infrastructure.Editor
    Assembly: Serenity.UnityProjectRecipe.Infrastructure.Editor.dll
    Syntax
    public sealed class SerenityRecipeAssetDatabase

    Constructors

    SerenityRecipeAssetDatabase(bool)

    Creates the wrapper.

    Declaration
    public SerenityRecipeAssetDatabase(bool dryRun)
    Parameters
    Type Name Description
    bool dryRun

    When true, all write operations become no-ops.

    Properties

    DryRun

    Declaration
    public bool DryRun { get; }
    Property Value
    Type Description
    bool

    When true, no folders or assets are written and nothing is marked dirty.

    Methods

    CreateAsset(Object, string)

    Creates a new asset at the given path. No-op in dry-run mode.

    Declaration
    public void CreateAsset(Object asset, string assetPath)
    Parameters
    Type Name Description
    Object asset

    The in-memory asset instance.

    string assetPath

    The destination path.

    EnsureFolders(string)

    Ensures that every folder in folderPath exists, creating missing folders from the top down. No-op in dry-run mode.

    Declaration
    public void EnsureFolders(string folderPath)
    Parameters
    Type Name Description
    string folderPath

    A project folder path (no trailing slash), e.g. Assets/Game/Audio.

    GetPresence(Type, string)

    Determines presence/type for a runtime Type (for type-driven imports).

    Declaration
    public RecipeAssetPresence GetPresence(Type type, string assetPath)
    Parameters
    Type Name Description
    Type type

    The expected asset type.

    string assetPath

    The project path to probe.

    Returns
    Type Description
    RecipeAssetPresence

    The presence/type classification.

    GetPresence<T>(string)

    Determines whether an asset exists at assetPath and whether it is of type T.

    Declaration
    public RecipeAssetPresence GetPresence<T>(string assetPath) where T : Object
    Parameters
    Type Name Description
    string assetPath

    The project path to probe.

    Returns
    Type Description
    RecipeAssetPresence

    The presence/type classification.

    Type Parameters
    Name Description
    T

    The expected asset type.

    Load<T>(string)

    Loads an existing asset of type T, or null when absent/incompatible.

    Declaration
    public T Load<T>(string assetPath) where T : Object
    Parameters
    Type Name Description
    string assetPath

    The project path.

    Returns
    Type Description
    T

    The loaded asset, or null.

    Type Parameters
    Name Description
    T

    The asset type to load.

    MarkDirty(Object)

    Marks an asset dirty so its changes persist on the next save. No-op in dry-run mode.

    Declaration
    public void MarkDirty(Object asset)
    Parameters
    Type Name Description
    Object asset

    The asset to mark dirty.

    RollbackCreated(IReadOnlyList<string>)

    Deletes the listed assets, newest first. Used to roll back a failed run. No-op in dry-run mode.

    Declaration
    public void RollbackCreated(IReadOnlyList<string> assetPaths)
    Parameters
    Type Name Description
    IReadOnlyList<string> assetPaths

    Paths created during the run, in creation order.

    SaveAll()

    Saves and refreshes the asset database. No-op in dry-run mode.

    Declaration
    public void SaveAll()
    In this article
    © 2026 Serenity. All Rights Reserved