Skip to content

Game.Prefabs.AmbienceEmitterPrefab

Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
A prefab component that configures an ambience emitter on an entity. When this prefab is applied during entity creation it adds the runtime AmbienceEmitter component/archetype entry and writes AmbienceEmitterData using the prefab's settings (group ambience type and intensity). This is used to place ambient sound/ambience emitters in the simulation via prefabs.


Fields

  • public GroupAmbienceType m_AmbienceType
    This field selects the type of group ambience that the emitter will produce. Set in the prefab (inspector or prefab file) and propagated into AmbienceEmitterData at initialization.

  • public float m_Intensity = 1f
    Intensity multiplier for the ambience emitter. Default is 1.0. Used to set the m_Intensity field on AmbienceEmitterData so the running system knows how loud/strong this emitter is.

Properties

  • None

Constructors

  • public AmbienceEmitterPrefab()
    Uses the default parameterless constructor (inherited). Prefab instances are typically serialized/created by the engine/editor; you normally configure fields via the prefab asset or inspector rather than constructing manually.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the component types that should be present on the entity as writable components for prefab data population. This implementation adds AmbienceEmitterData (read/write), indicating the prefab will supply initial data for that component.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds the runtime component types that will be part of the entity archetype. This implementation adds AmbienceEmitter (read/write), ensuring entities created from this prefab include the AmbienceEmitter component in their archetype.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called when the prefab is instantiated into an entity. This method sets the AmbienceEmitterData on the entity using the prefab fields:

  • m_AmbienceType is copied into AmbienceEmitterData.m_AmbienceType
  • m_Intensity is copied into AmbienceEmitterData.m_Intensity

This is where prefab-configured values are transferred to the ECS component data for runtime use.

Usage Example

// Prefab fields are set in the editor or by code. When the prefab is instantiated,
// the Initialize method runs and writes AmbienceEmitterData to the entity.
[ComponentMenu("Ambience/", new Type[] { })]
public class MyAmbiencePrefab : AmbienceEmitterPrefab
{
    // You can set m_AmbienceType and m_Intensity in inspector or constructor
    // The base Initialize implementation will write them into AmbienceEmitterData.
}