Skip to content

Game.Prefabs.Modes.ModeSettingParameters

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

Type: class

Base: PrefabBase

Summary:
Component/prefab helper used during prefab-to-entity conversion to ensure that the ModeSettingData component is present on the entity and that it is initialized with a default disabled state. The class is decorated with a ComponentMenu attribute so it can be placed on prefabs in the editor under the "Modes/" menu.


Fields

  • This class declares no instance fields.
    It only overrides prefab lifecycle methods to add and initialize components on the converted entity.

Properties

  • This class exposes no public properties.

Constructors

  • public ModeSettingParameters()
    Implicit parameterless constructor (not declared explicitly in source). The prefab system will construct instances when the prefab is loaded/inspected in the editor or when used by the prefab conversion pipeline.

Methods

  • public override void GetPrefabComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
    Adds the required component types to the prefab conversion set. This override calls the base implementation and then adds ModeSettingData as a ReadWrite component so the entity will include that component after conversion.

  • public override void Initialize(Unity.Entities.EntityManager entityManager, Unity.Entities.Entity entity)
    Called during prefab initialization / conversion. Calls the base implementation and then sets the ModeSettingData component on the provided entity with m_Enable = false, ensuring the mode is disabled by default when the entity is created.

Additional notes: - The class depends on Unity.Entities (ECS). The ComponentType.ReadWrite<ModeSettingData>() call registers that the resulting entity should contain a mutable ModeSettingData component. - The ModeSettingData struct is expected to be an IComponentData-like type with a boolean field m_Enable. This class sets that field to false during initialization.

Usage Example

// This is effectively what ModeSettingParameters does during prefab conversion.
[ComponentMenu("Modes/", new Type[] { })]
public class ModeSettingParameters : PrefabBase
{
    public override void GetPrefabComponents(HashSet<ComponentType> components)
    {
        base.GetPrefabComponents(components);
        components.Add(ComponentType.ReadWrite<ModeSettingData>());
    }

    public override void Initialize(EntityManager entityManager, Entity entity)
    {
        base.Initialize(entityManager, entity);
        entityManager.SetComponentData(entity, new ModeSettingData
        {
            m_Enable = false
        });
    }
}

This ensures that any prefab carrying this MonoBehaviour will produce an entity with a ModeSettingData component initialized to disabled when converted.