Skip to content

Game.Prefabs.StaticObjectPrefab

Assembly: Game
Namespace: Game.Prefabs

Type: class

Base: ObjectGeometryPrefab

Summary:
StaticObjectPrefab is a prefab class representing non-moving (static) objects in the game world. It extends ObjectGeometryPrefab and customizes the prefab and archetype component sets to include the game's static-object data and static marker components. It also augments the prefab's mod tags sequence to include "Prop" when the object is recognized as a prop by ModTags.IsProp(this). The class is decorated with a ComponentMenu attribute so it appears under "Objects/" in the component menu.


Fields

  • None
    This class declares no private or public fields in the provided source.

Properties

  • public override IEnumerable<string> modTags { get; }
    Returns the sequence of mod tags associated with the prefab. Implementation behavior:
  • Yields all tags from base.modTags.
  • If ModTags.IsProp(this) returns true, yields the additional tag "Prop".
  • Useful for tooling or mods that filter or identify prefabs by tags.

Constructors

  • No explicit constructors declared (uses the implicit default parameterless constructor)
    The class relies on the default constructor inherited from ObjectGeometryPrefab (or the implicit compiler-generated constructor) — nothing special is required to instantiate it beyond normal prefab creation patterns.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the component types required for instances of this prefab:
  • Calls base.GetPrefabComponents(components) to include base class behavior.
  • Adds ComponentType.ReadWrite<StaticObjectData>() so prefab instances include the StaticObjectData component (read/write).

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds the archetype-level components needed for this prefab:

  • Calls base.GetArchetypeComponents(components).
  • Adds ComponentType.ReadWrite<Static>() so entities created from this prefab include the Static marker component.

Notes: - ComponentType refers to Unity.Entities.ComponentType (used to build ECS archetypes). - StaticObjectData and Static are game-specific ECS components (from the game's data model) that mark and hold data for static objects.

Usage Example

Example 1 — deriving to add a custom component to the prefab:

public class MyCustomStaticPrefab : StaticObjectPrefab
{
    public override void GetPrefabComponents(HashSet<ComponentType> components)
    {
        base.GetPrefabComponents(components);
        components.Add(ComponentType.ReadWrite<MyCustomComponent>());
    }
}

Example 2 — inspecting mod tags at runtime:

var prefab = /* obtain prefab instance */;
foreach (var tag in prefab.modTags)
{
    if (tag == "Prop")
    {
        // treat this prefab as a prop (e.g. apply prop-specific behavior)
    }
}

{{ Additional information: - Attribute: The class is annotated with [ComponentMenu("Objects/", new Type[] { })], which is used by the editor/menu system. - Dependencies: Requires Unity.Entities for ComponentType and Game-specific components/types (StaticObjectData, Static). It also references ModTags (a helper for tag classification). - Typical use: Built-in prefab used by the game for static objects; modders typically derive from or reference this prefab when creating custom static object assets or when constructing entity archetypes for static items. }}