Class UnityStageService
Unity MonoBehaviour implementation of IStageService.
Supports a hybrid authoring model: Stage Prefab (spatial) + ScriptableObjects (tuning).
After instantiation, extracts IStageRoot, IRailPathAuthoring,
and ISpawnPointResolver from the prefab hierarchy.
Inheritance
UnityStageService
Assembly: Serenity.UnityStage.Infrastructure.dll
Syntax
public class UnityStageService : MonoBehaviour, IStageService, IService, IFoundationSettings, IUnityStageRuntime, IUnityStageRuntimeAsync
Constructors
UnityStageService()
Declaration
public UnityStageService()
Fields
LOG_CATEGORY
Declaration
protected const string LOG_CATEGORY = "StageService"
Field Value
_gameWrapper
Declaration
protected GameObject _gameWrapper
Field Value
| Type |
Description |
| GameObject |
|
_guid
Declaration
Field Value
_id
Declaration
Field Value
_logService
Declaration
protected ILogService _logService
Field Value
_spawnPointResolver
Declaration
protected ISpawnPointResolver _spawnPointResolver
Field Value
_stageInstance
Declaration
protected GameObject _stageInstance
Field Value
| Type |
Description |
| GameObject |
|
_stageRoot
Declaration
protected StageRoot _stageRoot
Field Value
_state
Declaration
protected StageState _state
Field Value
Properties
Guid
Declaration
public string Guid { get; set; }
Property Value
HasPreparedStage
Declaration
public bool HasPreparedStage { get; }
Property Value
Id
Declaration
public string Id { get; set; }
Property Value
IsPreparingStage
Declaration
public bool IsPreparingStage { get; }
Property Value
LogService
Declaration
public ILogService LogService { get; set; }
Property Value
SpawnPointResolver
The spawn point resolver extracted from the instantiated prefab, or null.
Declaration
public ISpawnPointResolver SpawnPointResolver { get; }
Property Value
StageRoot
The stage root extracted from the instantiated prefab, or null.
Declaration
public IStageRoot StageRoot { get; }
Property Value
Methods
BeginPrepareStagePrefab(GameObject)
Starts building stagePrefab in the background. Replaces any previous
preparation, cancelling and discarding it first. A null prefab clears the preparation
and does nothing else.
Declaration
public virtual void BeginPrepareStagePrefab(GameObject stagePrefab)
Parameters
| Type |
Name |
Description |
| GameObject |
stagePrefab |
|
CancelPreparedStage()
Abandons any in-flight or completed preparation and destroys whatever it produced.
Idempotent, and safe to call when nothing is prepared.
Declaration
public virtual void CancelPreparedStage()
CommitPreparedStage()
Activates the prepared stage, moves it into the live hierarchy, extracts its authoring
components and adopts it as the current stage.
Declaration
public virtual GameObject CommitPreparedStage()
Returns
| Type |
Description |
| GameObject |
The committed stage GameObject, or null when nothing was prepared or the preparation is
still running — callers should fall back to the synchronous path on null.
|
CompleteStage()
Declaration
public virtual void CompleteStage()
Reads the authoring components out of _stageInstance into this service's
slots. Extracted from InstantiateStagePrefab(GameObject) so the asynchronous path can
run the very same extraction at commit time rather than duplicating it — and so a
subclass adds its own extras by overriding one method instead of re-implementing
instantiation.
Declaration
protected virtual void ExtractAuthoringComponents()
FailStage()
Declaration
public virtual void FailStage()
GetSnapshot()
Declaration
public virtual StageSnapshot GetSnapshot()
Returns
InitializeService(IFoundationViewElement, ILogService)
Initializes the service with required dependencies.
Declaration
public virtual void InitializeService(IFoundationViewElement GameWrapper, ILogService logService)
Parameters
InstantiateStagePrefab(GameObject)
Instantiates the given stage prefab and extracts authoring components:
StageRoot, RailPathAuthoring, SpawnPointRegistry.
Declaration
public virtual GameObject InstantiateStagePrefab(GameObject stagePrefab)
Parameters
| Type |
Name |
Description |
| GameObject |
stagePrefab |
The stage prefab to instantiate.
|
Returns
| Type |
Description |
| GameObject |
The instantiated stage GameObject, or null if the prefab is null.
|
OnDestroy()
Declaration
protected virtual void OnDestroy()
StartStage(StageId)
Starts the stage with the given identity.
Declaration
public virtual void StartStage(StageId stageId)
Parameters
| Type |
Name |
Description |
| StageId |
stageId |
The stage identity.
|
Implements