Add/Remove/Modify/Limit Terrain Textures

Documentation for Unity Asset Store version v1.20

Summary

Terrain textures are defined in the scriptable object 'LE_TerrainTextureConfig'. The terrain texture config has three arrays: textures, texture sizes and texture offsets. The 'LE_ConfigTerrain', which is attached to the same game object as the 'LE_LevelEditorMain', has a link to the texture config, which can be seen in the inspector. Additionally, the maximal amount of textures for a single level can be limited in the 'LE_ConfigTerrain'. It is also possible to disable the base texture selection. The terrain texture config allows to reduce the level size, because the levels do not need to include the terrain textures. The serialized levels contain only an alphamap for every terrain texture. To assign the right alphamap to the right terrain texture when the level is loaded a terrain texture config is required.

Step 1: Find Your Terrain Texture Config

The scriptable object 'LE_TerrainTextureConfig' is located in your project (not in a scene). A simple way to find it is to open the level editor scene, then select the 'LE_LevelEditorMain' instance and double click on the 'Terrain Texture Config' property of the attached 'LE_ConfigTerrain' script in the inspector.


Step 2: Add/Remove/Modify Terrain Textures

To add, remove or modify the terrain textures you have to change the arrays contained in the scriptable object 'LE_TerrainTextureConfig'. The 'Terrain Textures' array contains references to the used textures. The 'Terrain Texture Sizes' array contains the size of each texture defined in the 'Terrain Textures' array. If the size is set to (10,10) then the texture will be repeated every 10 units. The 'Terrain Texture Offsets' array contains the offset of each texture defined in the 'Terrain Textures' array. Take a look at the Terrain Engine-Textures Unity manual for more information on these values. One more important information is that all three arrays must have the same length, because the texture at index 0 will get the size and offsets from the 0 index of the corresponding arrays.

Step 3: Limit The Number Of Terrain Textures Per Level

If you have added many terrain textures to your game, then you should limit the maximal number of terrain textures that can be used in a single level. Otherwise users might generate very performance intensive levels by using all terrain textures that you have provided in a single level. To change the maximal terrain texture count you have to set the 'Max Texture Count' property in the inspector of 'LE_ConfigTerrain' of the same game object to which the 'LE_LevelEditorMain' script is attached.

Step 4: Disable Base Texture Selection

If you want to use a specific texture as a base texture for all levels (for example a snow texture for a snowboarding game) then you should disable the base texture selection in the create terrain menu. Otherwise users could take a rock texture as the base texture, which would not fit to your snowboarding game. To disallow base texture selection set 'Is Base Texture Selection' to false in the inspector of the 'LE_ConfigTerrain' attached to the 'LE_LevelEditorMain' instance.
The level editor is completely independent of the UI implementation. The behaviour described above is true for the built-in UI example. Setting this property to false will suppress the call of the 'LE_GUIInterface.Delegates.SetTerrainBaseTextures' delegate. In the example UI the base texture selection is disabled by default and enabled as soon as the SetTerrainBaseTextures' is called. If you want to use a custom UI, then you can find more information in this article.