logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class SettingsAssetAuthoring

    Shared, engine-side (non-IMGUI) plumbing every single-settings-asset creation wizard needs: resolving the project-wide settings asset (explicit path, single existing asset, or none), Assets-path shape validation, recursive folder creation with a rollback-friendly created-paths trail, and a hardened asset-write check. Extracted from Serenity.GameProgress.Infrastructure.Editor.Builder.GameProgressCreator and Serenity.GameSave.Infrastructure.Editor.Builder.GameSaveCreator, which were byte-for-byte duplicating this exact logic. Serenity.Leaderboard.Infrastructure.Editor.Builder.LeaderboardCreator keeps its own private copy — it also resolves board uniqueness and a view/menu-option tree this shared helper knows nothing about, and touching its already-tested code is out of scope for this extraction.

    Inheritance
    object
    SettingsAssetAuthoring
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.StructuredPersistence.Infrastructure.Editor.Authoring
    Assembly: Serenity.UnityStructuredPersistence.Infrastructure.Editor.dll
    Syntax
    public static class SettingsAssetAuthoring

    Methods

    EnsureProjectFolderExists(string, ICollection<string>)

    Creates every missing segment of folderPath under the project's Assets folder, appending each newly created folder to createdPaths (shallowest first) so a caller's rollback can delete them in reverse order: assets first (appended last), then folders deepest-to-shallowest. A folder Unity's cache already reports as valid is left untouched. createdPaths takes any ICollection<T> — including Serenity.Global.Infrastructure.Editor.SerenityAssetCreationTransaction.FolderTracking — not just a concrete List<T>.

    Declaration
    public static void EnsureProjectFolderExists(string folderPath, ICollection<string> createdPaths)
    Parameters
    Type Name Description
    string folderPath
    ICollection<string> createdPaths

    IsWellFormedAssetsPath(string)

    Path-shape validation for a folder that will hold generated assets. A folder that does not exist yet is considered valid — EnsureProjectFolderExists(string, ICollection<string>) creates it during creation — this only rejects paths outside the project's Assets folder, or with empty/invalid segments.

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

    RequireProperty(SerializedObject, string)

    UnityEditor.SerializedObject.FindProperty(System.String) returns null — not an exception — for a field name that does not exist, so an unguarded chain like serializedObject.FindProperty("x").intValue = ... turns a renamed [SerializeField] into a NullReferenceException with no indication of which property or asset was involved. This resolves the property or throws a precise, self-diagnosing error instead.

    Declaration
    public static SerializedProperty RequireProperty(SerializedObject serializedObject, string propertyName)
    Parameters
    Type Name Description
    SerializedObject serializedObject
    string propertyName
    Returns
    Type Description
    SerializedProperty

    ResolveSettingsContext<TSettings>(string)

    Resolves the single project-wide TSettings asset: an explicit explicitSettingsAssetPath wins outright (a test seam and an already-known-asset fast path); otherwise a project-wide search returns the lone match, no match, or flags every path found when more than one exists (an ambiguity the caller must surface as an error).

    Declaration
    public static SettingsAssetAuthoring.SettingsResolution<TSettings> ResolveSettingsContext<TSettings>(string explicitSettingsAssetPath) where TSettings : Object
    Parameters
    Type Name Description
    string explicitSettingsAssetPath
    Returns
    Type Description
    SettingsAssetAuthoring.SettingsResolution<TSettings>
    Type Parameters
    Name Description
    TSettings

    VerifyAssetWasWrittenToDisk(string)

    UnityEditor.AssetDatabase.CreateAsset(UnityEngine.Object,System.String) logs a native engine error rather than throwing when its destination folder is valid in Unity's cache but has actually been removed from disk. This turns that silent failure into a genuine, catchable exception so a caller's rollback triggers deterministically instead of reporting success over a half-written project.

    Declaration
    public static void VerifyAssetWasWrittenToDisk(string assetPath)
    Parameters
    Type Name Description
    string assetPath
    In this article
    © 2026 Serenity. All Rights Reserved