Skip to content

Game.Prefabs.CullingEffect

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
CullingEffect is a prefab component used to mark effects with an audio culling group. When a prefab with this component is converted to an entity, it optionally adds and initializes a CullingGroupData component (used by the audio culling system) with a group index corresponding to the selected audio culling group. The class is exposed to Unity's Component menu via the [ComponentMenu("Effects/", typeof(EffectPrefab))] attribute so it can be added to effect prefabs in the editor.


Fields

  • public AudioCullingGroup m_AudioCullGroup
    The selected audio culling group for this effect. When set to a value other than AudioCullingGroup.None, the prefab conversion will add a CullingGroupData component to the entity and set its m_GroupIndex accordingly.

  • public enum AudioCullingGroup : byte
    Defines the available audio culling groups. Members:

  • None — no culling group; no CullingGroupData added.
  • Fire — group for fire-related sounds.
  • CarEngine — group for car engine sounds.
  • PublicTrans — group for public transport sounds.
  • Count — sentinel/size value.

Properties

  • This type does not declare public properties.

Constructors

  • public CullingEffect()
    Default parameterless constructor (implicit). Instances are typically created by adding the component to a prefab in the Unity editor.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    If m_AudioCullGroup != AudioCullingGroup.None, adds ComponentType.ReadWrite() to the provided set. This informs the conversion pipeline which components the entity prefab will require.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    No archetype components are declared by this class. Method is present to satisfy the ComponentBase API and can be extended by subclasses if needed.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    During entity initialization/conversion, if m_AudioCullGroup != AudioCullingGroup.None this method creates a CullingGroupData instance with m_GroupIndex set to the enum value and writes it to the entity via entityManager.SetComponentData(entity, componentData). Calls base.Initialize(...) first.

Usage Example

// Set the culling group in code (commonly done in editor by setting the field on the prefab)
var cullingEffect = gameObject.AddComponent<Game.Prefabs.CullingEffect>();
cullingEffect.m_AudioCullGroup = Game.Prefabs.CullingEffect.AudioCullingGroup.Fire;

// Result: when the prefab is converted to an entity, a CullingGroupData component
// with m_GroupIndex == (int)AudioCullingGroup.Fire will be added to the entity.