logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class SerenityRecipePathUtility

    Single source of truth for recipe path logic: normalising separators, combining a relative output path with the configured output root, and validating that the result stays under that root. No other type in the importer should build asset paths by hand.

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

    Methods

    CombineUnderRoot(string, string)

    Combines an output root with a relative output path. Both are normalised; the result is the project path the asset should live at.

    Declaration
    public static string CombineUnderRoot(string outputRoot, string relativeOutput)
    Parameters
    Type Name Description
    string outputRoot

    The (already normalised) output root, e.g. Assets/Game/SerenityGenerated.

    string relativeOutput

    The relative output path, e.g. Audio/SFX/Jump.asset.

    Returns
    Type Description
    string

    The combined, normalised project path.

    IsAssetFile(string)

    Returns true when the path ends in the Unity ScriptableObject extension .asset.

    Declaration
    public static bool IsAssetFile(string path)
    Parameters
    Type Name Description
    string path

    A path.

    Returns
    Type Description
    bool

    True for a .asset path.

    IsAssetPath(string)

    Returns true when the path is a valid project asset path (rooted at Assets).

    Declaration
    public static bool IsAssetPath(string path)
    Parameters
    Type Name Description
    string path

    A normalised path.

    Returns
    Type Description
    bool

    True when the path starts with Assets/ or equals Assets.

    IsUnderRoot(string, string)

    Returns true when fullPath is at or under root.

    Declaration
    public static bool IsUnderRoot(string root, string fullPath)
    Parameters
    Type Name Description
    string root

    The output root.

    string fullPath

    A combined project path.

    Returns
    Type Description
    bool

    True when the path stays under the root.

    IsUnsafeRelativeOutput(string)

    Returns true when a relative output path is unsafe: empty, absolute, drive-qualified, rooted at Assets, or containing a .. traversal segment.

    Declaration
    public static bool IsUnsafeRelativeOutput(string relativeOutput)
    Parameters
    Type Name Description
    string relativeOutput

    The recipe's relative output path.

    Returns
    Type Description
    bool

    True when the path must be rejected.

    Leaf(string)

    Returns the final segment (file or folder name) of a path.

    Declaration
    public static string Leaf(string path)
    Parameters
    Type Name Description
    string path

    A normalised path.

    Returns
    Type Description
    string

    The leaf segment.

    Normalize(string)

    Normalises a path to forward slashes, trims whitespace, and removes a trailing slash.

    Declaration
    public static string Normalize(string path)
    Parameters
    Type Name Description
    string path

    The path to normalise.

    Returns
    Type Description
    string

    The normalised path, or an empty string when path is null/empty.

    ParentFolder(string)

    Returns the parent folder of a path, or empty when there is none.

    Declaration
    public static string ParentFolder(string path)
    Parameters
    Type Name Description
    string path

    A normalised path.

    Returns
    Type Description
    string

    The parent folder path.

    RelativeTo(string, string)

    Expresses fullPath relative to root — the inverse of CombineUnderRoot(string, string), used by the exporter to compute a recipe's relative output. When the path is not under the root, a leading Assets/ is stripped so it still nests sensibly when re-imported.

    Declaration
    public static string RelativeTo(string root, string fullPath)
    Parameters
    Type Name Description
    string root

    The output/scan root.

    string fullPath

    The asset's project path.

    Returns
    Type Description
    string

    The path relative to the root.

    In this article
    © 2026 Serenity. All Rights Reserved