Skip to content

Game.Rendering.TerrainMaterialPropertiesPrefab

Assembly: Assembly-CSharp
Namespace: Game.Rendering

Type: class

Base: PrefabBase

Summary:
Prefab wrapper that exposes terrain-related material settings to the prefab system. This prefab holds a reference to a splatmap material (used for terrain texture blending) and ensures that the corresponding ECS component (TerrainMaterialPropertiesData) is added to entities created from the prefab. Intended for use with the game's prefab / ECS bootstrap so terrain material properties are present on the entity that represents the terrain.


Fields

  • public UnityEngine.Material m_SplatmapMaterial
    Holds a reference to the Material used for terrain splatmap rendering/blending. This field is serialized/inspected in the prefab asset so designers can drop in the appropriate terrain splatmap material. The runtime code does not manipulate the Material beyond making it available via the prefab instance.

  • (inherited) Any fields from PrefabBase are also available; this class only declares the splatmap material field.

Properties

  • This type declares no public properties.

Constructors

  • public TerrainMaterialPropertiesPrefab()
    No explicit constructor is defined in source; the default parameterless constructor is used. Any necessary initialization should be done via prefab setup in the editor or by overriding lifecycle methods on PrefabBase (if available).

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds component descriptors required by this prefab to the provided HashSet. Implementation calls the base override and then adds a read/write ECS component entry for TerrainMaterialPropertiesData via: components.Add(ComponentType.ReadWrite()); This ensures entities instantiated from this prefab include the TerrainMaterialPropertiesData component so systems that read or write terrain material properties can operate.

Usage Example

// Example: A prefab asset in the editor should have its m_SplatmapMaterial assigned.
// The prefab system will call GetPrefabComponents when converting/instantiating the prefab,
// making sure the TerrainMaterialPropertiesData component is present on the entity.

public class MyTerrainPrefabCreator
{
    public void RegisterPrefab(TerrainMaterialPropertiesPrefab prefab)
    {
        // Prefab has a Material assigned in the inspector:
        Material splat = prefab.m_SplatmapMaterial;

        // During conversion, the engine will call:
        var components = new HashSet<ComponentType>();
        prefab.GetPrefabComponents(components);
        // components now contains ComponentType.ReadWrite<TerrainMaterialPropertiesData>()
    }
}

{{ Additional notes: - TerrainMaterialPropertiesData is expected to be an IComponentData (or similar ECS component) defined elsewhere; this prefab does not define that data type. - Assign m_SplatmapMaterial in the prefab inspector so runtime systems can reference the correct material. - If you need to add more ECS components to the prefab, extend GetPrefabComponents and add the required ComponentType entries (remember to call base.GetPrefabComponents). }}