logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class SerenitySampleSceneGenerator

    Generates the demo scene Assets/Documentation/SAMPLE_SCENE_GUIDE.md walks a designer through by hand: a Canvas/EventSystem, the Diagnostics Overlay, a reusable Toast prefab, and a button that shows it directly. The guide's signal-emitter/reaction chain is intentionally not generated — it depends on IEventDispatcherService, which only the boot pipeline registers, so it would silently do nothing in this standalone scene (see section 5 of the guide for adding it by hand in a booted project).

    Hand-authoring the resulting .unity/.prefab YAML is unreviewable and unmaintainable, so this is a deterministic C# generator instead: a human runs it once via the menu item below, and its output is reproducible and unit-testable (see Generate(string), which every test drives directly against a disposable output folder instead of the shipped one).

    Mirrors ThemeCreator/SignalDefinitionCreator: a static class, a SerenitySampleSceneGenerator.Result DTO, created-paths rollback on failure, and Addressables registration only after the whole run succeeds.

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

    Methods

    Generate(string)

    Builds every step of the guide into a fresh scene under rootFolder and saves it. Aborts before touching the project when TMP Essential Resources are not installed — TMP Essentials may not be imported yet, and generating a Toast/Button prefab without a resolvable TMP_Settings asset would silently ship a broken prefab instead. Mirrors the primary, authoritative signal SerenityTmpEssentialsValidator itself checks first (a TMP_Settings asset resolving under Resources); that validator exposes no public synchronous query, so the same check is replicated here via the null-safe TMPro.TMP_Settings.instance rather than reflecting into its internals.

    Declaration
    public static SerenitySampleSceneGenerator.Result Generate(string rootFolder)
    Parameters
    Type Name Description
    string rootFolder

    Output folder for the scene and prefab. Tests pass a disposable temp folder here instead of Serenity.SampleScene.Infrastructure.Editor.SampleSceneAssetPaths.DefaultRootFolder.

    Returns
    Type Description
    SerenitySampleSceneGenerator.Result

    GenerateSampleScene()

    Generates the sample scene into the shipped package location. Idempotent: rerunning updates the existing scene/prefab in place rather than duplicating them.

    Declaration
    public static void GenerateSampleScene()
    Remarks

    Generation replaces whatever scene is currently open, so the user is given the chance to save first. The prompt lives here rather than in Generate(string) because that method is the testable API: a headless run must never block on a dialog.

    In this article
    © 2026 Serenity. All Rights Reserved