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
UnityServiceHost
Assembly: Serenity.UnityGlobal.Infrastructure.dll
Syntax
public static class UnityServiceHost
Methods
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 |
|
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 |
|