Skip to content

Game.Prefabs.Modes.LocalModePrefab

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

Type: abstract class

Base: ModePrefab

Summary:
LocalModePrefab is an abstract base class for prefab definitions that represent a "local mode" in the game. It defines lifecycle hooks for applying mode-specific data to entities and prefabs (ApplyModeData), restoring defaults (RestoreDefaultData), and optionally recording changes during development builds (RecordChanges). These methods interact with the Unity.Entities.EntityManager and the game's PrefabSystem to modify prefab-related data at runtime or while editing in development/editor builds.


Fields

  • This class declares no instance fields.
    Additional implementation classes may introduce their own fields to store mode-specific state.

Properties

  • This class declares no properties.
    Use derived classes to expose any required properties.

Constructors

  • public LocalModePrefab()
    This class has no explicit constructor in source; the parameterless public constructor is provided implicitly. Derived types should call base() implicitly or explicitly if a custom constructor is added.

Methods

  • public abstract void ApplyModeData(EntityManager entityManager, PrefabSystem prefabSystem)
    Apply mode-specific data to entities and prefabs. Implementations should use the provided EntityManager and PrefabSystem to create, modify or configure ECS entities and prefab state needed for this local mode.

  • public abstract void RestoreDefaultData(EntityManager entityManager, PrefabSystem prefabSystem)
    Restore default prefab/entity data for this mode. Implementations should undo or reset changes applied by ApplyModeData so that prefabs return to their default state (for example when switching modes).

  • [Conditional("UNITY_EDITOR")]
    [Conditional("DEVELOPMENT_BUILD")]
    public virtual void RecordChanges(EntityManager entityManager, PrefabSystem prefabSystem)
    A virtual method intended to record or log changes made to prefabs/entities. Marked with Conditional attributes so calls to this method are only included and executed in UNITY_EDITOR or DEVELOPMENT_BUILD builds — in release builds the calls will be omitted by the compiler. Deriving types can override this method to capture edit-time changes (for example to assist debugging or to generate change records).

Usage Example

public class MyLocalModePrefab : LocalModePrefab
{
    public override void ApplyModeData(EntityManager entityManager, PrefabSystem prefabSystem)
    {
        // Apply mode-specific components or settings to prefabs/entities here
        // e.g. add a component or set prefab parameters using prefabSystem
    }

    public override void RestoreDefaultData(EntityManager entityManager, PrefabSystem prefabSystem)
    {
        // Revert changes done in ApplyModeData so objects return to defaults
    }

    [Conditional("UNITY_EDITOR")]
    [Conditional("DEVELOPMENT_BUILD")]
    public override void RecordChanges(EntityManager entityManager, PrefabSystem prefabSystem)
    {
        // Record or log edits while in editor / development build.
        // This method will be stripped out of release builds.
    }
}

Notes: - ApplyModeData and RestoreDefaultData are required to be implemented by derived classes. - Use the RecordChanges method to capture edit-time changes; the Conditional attributes mean you don't need #if guards around calls — calls are compiled out automatically in non-development/release builds.