Game.Prefabs.MeshSettings
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
MeshSettings is a prefab component that holds references to fallback and default mesh prefabs used by the rendering / networking systems. It exposes three prefab references (missing object mesh, default base mesh and missing net section). During LateInitialize these prefab references are resolved by the PrefabSystem into Entity references and stored in a MeshSettingsData component on the prefab entity. The class is registered in the component menu for use with RenderingSettingsPrefab via the ComponentMenu attribute.
Fields
-
public RenderPrefab m_MissingObjectMesh
Reference to a RenderPrefab used when an expected object mesh is missing. Included in prefab dependencies and resolved to an Entity in LateInitialize. -
public RenderPrefab m_DefaultBaseMesh
Reference to a default base RenderPrefab used as a fallback base mesh. Included in prefab dependencies and resolved to an Entity in LateInitialize. -
public NetSectionPrefab m_MissingNetSection
Reference to a NetSectionPrefab used when a net section mesh is missing. Included in prefab dependencies and resolved to an Entity in LateInitialize.
Properties
- (none)
Constructors
public MeshSettings()
Default, compiler-generated constructor. The class does not define an explicit constructor and relies on default initialization.
Methods
-
public override void GetDependencies(List<PrefabBase> prefabs)
Adds m_MissingObjectMesh, m_DefaultBaseMesh and m_MissingNetSection to the supplied dependencies list so the PrefabSystem knows those prefabs must be available/loaded. -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Registers the runtime component type added to the prefab entity: MeshSettingsData (ReadWrite). This tells the prefab system that the prefab entity will have a MeshSettingsData component. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
No archetype components are added by this prefab component (method intentionally empty). -
public override void LateInitialize(EntityManager entityManager, Entity entity)
Resolves the referenced prefabs to Entities using the PrefabSystem and writes a MeshSettingsData instance on the prefab entity: - Fetches PrefabSystem from entityManager.World.GetExistingSystemManaged
() - Calls GetEntity(...) for each prefab reference
- Constructs MeshSettingsData with those Entity references
- Calls entityManager.SetComponentData(entity, componentData)
Usage Example
// Example: reading resolved MeshSettingsData from a prefab entity
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity prefabEntity = /* the prefab entity that has MeshSettingsData */;
if (entityManager.HasComponent<MeshSettingsData>(prefabEntity))
{
var meshSettings = entityManager.GetComponentData<MeshSettingsData>(prefabEntity);
Entity missingObjectMeshEntity = meshSettings.m_MissingObjectMesh;
Entity defaultBaseMeshEntity = meshSettings.m_DefaultBaseMesh;
Entity missingNetSectionEntity = meshSettings.m_MissingNetSection;
// Use the entity references to lookup render data, meshes, etc.
}
Notes and tips: - The prefab fields (RenderPrefab / NetSectionPrefab) are Editor-assigned; at runtime they are resolved to Entity handles in LateInitialize. - Ensure the referenced prefabs are included in the same prefab package or loaded before LateInitialize runs, otherwise GetEntity may return Entity.Null. - MeshSettingsData is the runtime ECS component backing this prefab component; inspect that struct to see exact field names/types if you need to read/write it directly.