Game.DefaultMesh
Assembly: Game
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
DefaultMesh is a lightweight component class used by the prefab system to represent a default rendering mesh prefab. The class is decorated with a ComponentMenu attribute targeting the "Rendering/" menu and referencing RenderPrefab, which indicates it is intended for use with rendering-related prefab workflows. The source provides two override hooks (GetArchetypeComponents and GetPrefabComponents) that allow the component to declare which ECS component types should be present on an entity archetype or prefab, but both methods are empty in this implementation — making DefaultMesh effectively a marker/placeholder until specific components are added by derived classes or by mod authors.
Fields
- This class does not declare any instance or static fields.
DefaultMesh contains no backing data; it is a behavior/metadata component for prefabs.
Properties
- This class does not declare any properties.
State and configuration are expected to be represented via added ECS components rather than class properties.
Constructors
public DefaultMesh()
The default parameterless constructor is implied. No custom initialization is performed in the class.
Methods
-
public override void GetArchetypeComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
DefaultMesh overrides this hook to allow the component to contribute component types to an entity archetype. The method is empty in the provided implementation. Modders should add ComponentType entries here if they want every entity of the archetype to contain specific ECS components (for example render-related components). -
public override void GetPrefabComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
This override allows the component to declare which component types should be present when creating a prefab from this component. It is also empty in the provided implementation. Typical usage is to add ComponentType.ReadWrite() or ComponentType.ReadOnly () entries for components like RenderMesh, LocalToWorld, or any custom components required by the prefab.
Usage Example
// Example: declare render-related ECS components for this prefab.
[ComponentMenu("Rendering/", new Type[] { typeof(RenderPrefab) })]
public class DefaultMesh : ComponentBase
{
public override void GetArchetypeComponents(HashSet<ComponentType> components)
{
// Ensure archetype entities include these components by default.
components.Add(ComponentType.ReadWrite<RenderMesh>());
components.Add(ComponentType.ReadWrite<LocalToWorld>());
}
public override void GetPrefabComponents(HashSet<ComponentType> components)
{
// Ensure prefabs created from this component include these components.
components.Add(ComponentType.ReadWrite<RenderMesh>());
components.Add(ComponentType.ReadWrite<LocalToWorld>());
}
}
Notes and recommendations:
- The provided source leaves both component-declaration methods empty. If you are creating a custom prefab that needs rendering, add the required ComponentType entries (RenderMesh, LocalToWorld, per-instance material, etc.) in these methods.
- Use ComponentType.ReadWrite