Skip to content

Game.Prefabs.FencePrefab

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: NetGeometryPrefab

Summary:
FencePrefab is a prefab class used for fence network geometry. It extends NetGeometryPrefab and registers the FenceData component (as read/write) to the prefab's component set so that entities created from this prefab will have FenceData available. The class also overrides the archetype components method but does not add extra archetype components beyond its base.


Fields

  • None
    No private or public fields are declared in this class.

Properties

  • None
    The class does not declare any properties.

Constructors

  • public FencePrefab()
    Default public constructor inherited from the class. There is no custom construction logic implemented in this source file.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the prefab-specific components to the provided set. Calls the base implementation to include base prefab components and then adds ComponentType.ReadWrite() so that entities instantiated from this prefab include FenceData as a readable/writable component.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Calls the base implementation to populate archetype components. This override does not add any additional components beyond what NetGeometryPrefab provides.

Additional notes: - The class has the attribute [ComponentMenu("Net/Prefab/", new Type[] { })], which places the prefab entry under the "Net/Prefab/" menu in Unity's inspector (or is used by the game's tooling to categorize the prefab). - FenceData must be defined elsewhere in the project; FencePrefab only registers it for entities created from this prefab.

Usage Example

using System;
using System.Collections.Generic;
using Unity.Entities;
using Game.Prefabs;

// Example: collecting the prefab components registered by FencePrefab
var prefab = new FencePrefab();
var components = new HashSet<ComponentType>();
prefab.GetPrefabComponents(components);

// 'components' now contains the base prefab component types plus:
// ComponentType.ReadWrite<FenceData>()