Game.Prefabs.AudioGroupingSettingsPrefab
Assembly:
Namespace: Game.Prefabs
Type: class
Base: PrefabBase
Summary:
Prefab component that defines grouping settings for audio. Exposes an array of AudioGroupSettings (m_Settings) which are turned into a DynamicBuffer
Fields
public AudioGroupSettings[] m_Settings
Holds the collection of audio group configuration entries (type, fade speed, scale, referenced sound prefabs, heights, weights, etc.). Each entry is converted into an AudioGroupingSettingsData element in the entity buffer during LateInitialize.
Properties
- (none)
Constructors
public AudioGroupingSettingsPrefab()
Implicit default constructor. No custom construction logic is defined in the class.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds component type requirements for this prefab to the provided set. Specifically adds ComponentType.ReadWrite() so the prefab entity will carry a DynamicBuffer . Calls base.GetPrefabComponents(components). -
public override void GetDependencies(List<PrefabBase> prefabs)
Iterates m_Settings (if not null) and adds referenced prefabs (m_GroupSoundFar and m_GroupSoundNear) to the provided prefabs list. This ensures referenced sound prefabs are treated as dependencies and available as entities when this prefab is initialized. Calls base.GetDependencies(prefabs) afterwards. -
public override void LateInitialize(EntityManager entityManager, Entity entity)
Converts the inspector/populated m_Settings array into actual runtime AudioGroupingSettingsData buffer entries on the prefab entity. Uses PrefabSystem (obtained via entityManager.World.GetOrCreateSystemManaged()) to map referenced PrefabBase instances to Entities with GetEntity(...). Adds a new AudioGroupingSettingsData to the prefab entity's DynamicBuffer for each AudioGroupSettings entry, copying fields: - m_Type, m_FadeSpeed, m_Scale
- m_GroupSoundFar -> mapped Entity
- m_GroupSoundNear -> mapped Entity or Entity.Null if null
- m_Height, m_NearHeight, m_NearWeight
Usage Example
// Example: populate the prefab in editor code or via another initializer.
// AudioGroupSettings fields inferred from usage in LateInitialize:
// m_Type, m_FadeSpeed, m_Scale, m_GroupSoundFar, m_GroupSoundNear, m_Height, m_NearHeight, m_NearWeight
public AudioGroupSettings[] m_Settings = new[]
{
new AudioGroupSettings
{
m_Type = AudioGroupType.Vehicle,
m_FadeSpeed = 1.0f,
m_Scale = 1.0f,
m_GroupSoundFar = someFarSoundPrefab, // PrefabBase reference
m_GroupSoundNear = someNearSoundPrefab, // PrefabBase reference (can be null)
m_Height = 10f,
m_NearHeight = 5f,
m_NearWeight = 0.6f
}
};
// Runtime: the game's prefab system will call LateInitialize which populates
// the entity's DynamicBuffer<AudioGroupingSettingsData> from m_Settings.