177 lines
4.5 KiB
C#
177 lines
4.5 KiB
C#
using LE_LevelEditor.Core;
|
|
using UnityEngine;
|
|
|
|
namespace LE_LevelEditor
|
|
{
|
|
public class LE_ConfigTerrain : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
[Tooltip("Scene object with a 'Projector' component that will be used to project the terrain edit brush. Can be 'null' if 'LE_LevelEditorMain.IS_TERRAIN_EDITOR' is 'false'.")]
|
|
private Projector m_brushProjector;
|
|
|
|
[SerializeField]
|
|
[Tooltip("Array with selectable brush textures.")]
|
|
private Texture2D[] m_brushes = new Texture2D[0];
|
|
|
|
[Tooltip("Terrain texture configuration must be assigned! Assign an empty asset if needed...")]
|
|
[SerializeField]
|
|
private LE_TerrainTextureConfig m_terrainTextureConfig;
|
|
|
|
[Tooltip("Set a predefined Unity terrain scene object.")]
|
|
[SerializeField]
|
|
private Terrain m_customDefaultTerrain;
|
|
|
|
[Tooltip("Created/loaded terrains will be moved to this layer. Raycast layer for terrain editing and terrain snapped object placement.")]
|
|
[SerializeField]
|
|
private int m_terrainLayer = 28;
|
|
|
|
[SerializeField]
|
|
[Tooltip("Float array with increasing size limits. Must have the same length as 'HeightmapResolutions'. When a terrain is created, then the used resolution index (from 'HeightmapResolutions') will be the highest index, that has a smaller or equal size (in 'HeightmapResolutionSizes') than the terrain width and length. In the example on the right a terrain with 200 units size would get a heightmap resolution of 65 and a terrain with a size of 300 would have a resolution of 129.")]
|
|
private float[] m_heightmapResolutionSizes = new float[0];
|
|
|
|
[SerializeField]
|
|
[Tooltip("Int array with increasing heightmap resolutions. Must have the same length as 'HeightmapResolutionSizes'. Values must be power of two plus 1.")]
|
|
private int[] m_heightmapResolutions = new int[0];
|
|
|
|
[Tooltip("Float array with increasing size limits. Must have the same length as 'AlphamapResolutions'. When a terrain is created, then the used resolution index (from 'AlphamapResolutions') will be the highest index, that has a smaller or equal size (in 'AlphamapResolutionSizes') than the terrain width and length. In the example on the right a terrain with 200 units size would get a heightmap resolution of 64 and a terrain with a size of 300 would have a resolution of 128.")]
|
|
[SerializeField]
|
|
private float[] m_alphamapResolutionSizes = new float[0];
|
|
|
|
[SerializeField]
|
|
[Tooltip("Int array with increasing alphamap resolutions. Must have the same length as 'AlphamapResolutionSizes'. Values must be power of two.")]
|
|
private int[] m_alphamapResolutions = new int[0];
|
|
|
|
[Tooltip("The maximal count of textures that a terrain can have. It will be not possible to add more textures when the limit is reached.")]
|
|
[SerializeField]
|
|
private int m_maxTextureCount = 3;
|
|
|
|
[Tooltip("Player can choose a base texture for his terrain if enabled. The first texture from the 'TerrainTextureConfig' will be used if disabled.")]
|
|
[SerializeField]
|
|
private bool m_isBaseTextureSelection = true;
|
|
|
|
[Tooltip("The default width value in the create terrain menu.")]
|
|
[SerializeField]
|
|
private int m_initialWidth = 500;
|
|
|
|
[Tooltip("The default height value in the create terrain menu.")]
|
|
[SerializeField]
|
|
private int m_initialHeight = 250;
|
|
|
|
[Tooltip("The default length value in the create terrain menu.")]
|
|
[SerializeField]
|
|
private int m_initialLength = 500;
|
|
|
|
public Projector BrushProjector
|
|
{
|
|
get
|
|
{
|
|
return m_brushProjector;
|
|
}
|
|
}
|
|
|
|
public Texture2D[] Brushes
|
|
{
|
|
get
|
|
{
|
|
return m_brushes;
|
|
}
|
|
}
|
|
|
|
public LE_TerrainTextureConfig TerrainTextureConfig
|
|
{
|
|
get
|
|
{
|
|
return m_terrainTextureConfig;
|
|
}
|
|
}
|
|
|
|
public Terrain CustomDefaultTerrain
|
|
{
|
|
get
|
|
{
|
|
return m_customDefaultTerrain;
|
|
}
|
|
}
|
|
|
|
public int TerrainLayer
|
|
{
|
|
get
|
|
{
|
|
return m_terrainLayer;
|
|
}
|
|
}
|
|
|
|
public float[] HeightmapResolutionSizes
|
|
{
|
|
get
|
|
{
|
|
return m_heightmapResolutionSizes;
|
|
}
|
|
}
|
|
|
|
public int[] HeightmapResolutions
|
|
{
|
|
get
|
|
{
|
|
return m_heightmapResolutions;
|
|
}
|
|
}
|
|
|
|
public float[] AlphamapResolutionSizes
|
|
{
|
|
get
|
|
{
|
|
return m_alphamapResolutionSizes;
|
|
}
|
|
}
|
|
|
|
public int[] AlphamapResolutions
|
|
{
|
|
get
|
|
{
|
|
return m_alphamapResolutions;
|
|
}
|
|
}
|
|
|
|
public int MaxTextureCount
|
|
{
|
|
get
|
|
{
|
|
return m_maxTextureCount;
|
|
}
|
|
}
|
|
|
|
public bool IsBaseTextureSelection
|
|
{
|
|
get
|
|
{
|
|
return m_isBaseTextureSelection;
|
|
}
|
|
}
|
|
|
|
public int InitialWidth
|
|
{
|
|
get
|
|
{
|
|
return m_initialWidth;
|
|
}
|
|
}
|
|
|
|
public int InitialHeight
|
|
{
|
|
get
|
|
{
|
|
return m_initialHeight;
|
|
}
|
|
}
|
|
|
|
public int InitialLength
|
|
{
|
|
get
|
|
{
|
|
return m_initialLength;
|
|
}
|
|
}
|
|
}
|
|
}
|