logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityServiceHost

    The "create a GameObject, name it, add the hosting component" boilerplate repeated by every Unity service factory (see UnityTimerServiceFactory, UnitySoundMixerServiceFactory, UnityLocalizationServiceFactory, and the rest). Deliberately does NOT call Object.DontDestroyOnLoad — factories differ on whether the service GameObject should survive a scene load, so that call stays at each call site rather than being folded in here.

    Inheritance
    object
    UnityServiceHost
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Global.Infrastructure.Utils
    Assembly: Serenity.UnityGlobal.Infrastructure.dll
    Syntax
    public static class UnityServiceHost

    Methods

    CreateHost(string, Transform)

    Creates a bare "host" GameObject named name with no component attached — for container GameObjects that other objects (e.g. audio emitters) get parented under. Optionally parents it under parent (world position is not preserved).

    Declaration
    public static GameObject CreateHost(string name, Transform parent = null)
    Parameters
    Type Name Description
    string name
    Transform parent
    Returns
    Type Description
    GameObject

    Create<TComponent>(string)

    Creates a new GameObject named name and adds TComponent to it.

    Declaration
    public static TComponent Create<TComponent>(string name) where TComponent : Component
    Parameters
    Type Name Description
    string name
    Returns
    Type Description
    TComponent
    Type Parameters
    Name Description
    TComponent

    Create<TComponent>(string, Transform)

    Creates a new GameObject named name, adds TComponent to it, and parents it under parent (world position is not preserved, matching Transform.SetParent(parent, false)). No-op parenting when parent is null.

    Declaration
    public static TComponent Create<TComponent>(string name, Transform parent) where TComponent : Component
    Parameters
    Type Name Description
    string name
    Transform parent
    Returns
    Type Description
    TComponent
    Type Parameters
    Name Description
    TComponent
    In this article
    © 2026 Serenity. All Rights Reserved