Class VisualChunkMeshLayerConfigAsset
Defines a ScriptableObject asset that configures the rendering and visual properties for a chunk mesh layer in a hex terrain system.
Inheritance
Inherited Members
Namespace: Fwt.HexTerrains.ChunkMehes.Data
Assembly: fwt.hexterrains.dll
Syntax
[CreateAssetMenu(fileName = "VisualChunkMeshLayerConfigAsset", menuName = "Fwt/HexTerrains/ChunkMeshes/VisualChunkMeshLayerConfigAsset")]
public class VisualChunkMeshLayerConfigAsset : ChunkMeshLayerConfigAsset, ITerrainLayerFactory, IVisualChunkMeshLayerConfig, IChunkMeshLayerConfig
Remarks
This asset provides settings for controlling the visibility, rendering parameters, surface render configurations, and biome UV mappings for a visual chunk mesh layer. It is intended to be used within the Unity Editor to customize how terrain chunks are rendered, including support for multiple view modes and biome-specific UVs. The asset can be created via the Unity asset menu and is typically referenced by terrain generation or rendering systems.
Fields
_biomeUvs
Declaration
[Tooltip("UVs for the hex surface biomes. In standard case the UV index = biome index.\nUsed if IsUseBiomeAtlas is true.")]
[SerializeField]
protected List<Sprite> _biomeUvs
Field Value
| Type | Description |
|---|---|
| List<Sprite> |
_defaultRenderConfig
Declaration
[Tooltip("If there is no render config for the view mode found, this config will be used as a fallback.")]
[SerializeField]
protected HexSurfaceRenderConfigAsset _defaultRenderConfig
Field Value
| Type | Description |
|---|---|
| HexSurfaceRenderConfigAsset |
_isVisible
Declaration
[Tooltip("If true, the layer will be rendered.")]
[SerializeField]
protected bool _isVisible
Field Value
| Type | Description |
|---|---|
| bool |
_renderConfigs
Declaration
[Tooltip("Render configurations for the surface layer. Used to get materials and params like IsCastShadows, IsReceive Shadows, etc.\nIndex of the config in this list corresponds to the view mode of the terrain.\nWhen the view mode == 0, the first config will be used, when view mode == 1, the second config will be used, etc.")]
[SerializeField]
protected List<HexSurfaceRenderConfigAsset> _renderConfigs
Field Value
| Type | Description |
|---|---|
| List<HexSurfaceRenderConfigAsset> |
_renderSettings
Declaration
[Tooltip("Contains settings for rendering chunk meshes.")]
[SerializeField]
protected ChunkMeshRenderSettings _renderSettings
Field Value
| Type | Description |
|---|---|
| ChunkMeshRenderSettings |
Properties
BiomeUVConfigs
Gets an enumerable collection of biome UV configuration objects for the chunk mesh.
Declaration
public IEnumerable<ChunkMeshBiomeUVConfig> BiomeUVConfigs { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<ChunkMeshBiomeUVConfig> |
BiomeUvs
UVs for the hex surface biomes. In standard case the UV index = biome index. Used if IsUseBiomeAtlas is true.
Declaration
public List<Sprite> BiomeUvs { get; set; }
Property Value
| Type | Description |
|---|---|
| List<Sprite> |
DefaultRenderConfig
If there is no render config for the view mode found, this config will be used as a fallback.
Declaration
public HexSurfaceRenderConfigAsset DefaultRenderConfig { get; set; }
Property Value
| Type | Description |
|---|---|
| HexSurfaceRenderConfigAsset |
IsVisible
If true, the layer will be rendered.
Declaration
public bool IsVisible { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
RenderConfigs
Render configurations for the surface layer. Used to get materials and params like IsCastShadows, IsReceive Shadows, etc. Index of the config in this list corresponds to the view mode of the terrain. When the view mode == 0, the first config will be used, when view mode == 1, the second config will be used, etc.
Declaration
public List<HexSurfaceRenderConfigAsset> RenderConfigs { get; set; }
Property Value
| Type | Description |
|---|---|
| List<HexSurfaceRenderConfigAsset> |
RenderSettings
Contains settings for rendering chunk meshes.
Declaration
public ChunkMeshRenderSettings RenderSettings { get; set; }
Property Value
| Type | Description |
|---|---|
| ChunkMeshRenderSettings |
Methods
CreateTerrainLayer()
Creates a terrain layer using the specified initialization arguments.
Declaration
public override HexTerrainLayer CreateTerrainLayer()
Returns
| Type | Description |
|---|---|
| HexTerrainLayer | created terrain layer |
Overrides
ExtractUVFromSprite(Sprite, float4)
Extracts the minimum and maximum UV coordinates from the specified sprite. Returns the provided fallback value if the sprite is null or does not contain valid UV data.
Declaration
public virtual float4 ExtractUVFromSprite(Sprite sprite, float4 fallback)
Parameters
| Type | Name | Description |
|---|---|---|
| Sprite | sprite | The sprite from which to extract UV coordinates. If null or if the sprite's UV array is invalid, the fallback value is returned. |
| float4 | fallback | The value to return if the sprite is null or does not contain at least four UV coordinates. |
Returns
| Type | Description |
|---|---|
| float4 | A float4 containing the minimum (x, y) and maximum (z, w) UV coordinates of the sprite. Returns the fallback value if the sprite is null or its UV data is invalid. |
GetBiomeConfigs()
Returns an enumerable collection of biome UV configuration objects for the current set of biome sprites.
Declaration
public virtual IEnumerable<ChunkMeshBiomeUVConfig> GetBiomeConfigs()
Returns
| Type | Description |
|---|---|
| IEnumerable<ChunkMeshBiomeUVConfig> | An enumerable collection of ChunkMeshBiomeUVConfig instances representing the UV configurations for each biome. If no biome sprites are defined, the collection contains a single default configuration. |
Remarks
The returned collection will skip any null entries in the underlying biome sprite list. If the biome sprite list is null or empty, a default configuration with full UV coverage is returned.