Component to convert 3D models into Unity Terrain. Can work as with all objects on a layer, and only the selected objects. Does not require the addition of the components of physics.
Add the 3D scene model that you want to convert into Terrain. The number of models is not limited, and they can have any nesting.
Important: You can use any model, but Unity Terrains can only be rectangular.
Select the menu item «Window / Infinity Code / Mesh to Terrain», to open the component.
Window component consists of three sections:
- Meshes – List of mesh, which will be converted into terrains, and general conversion settings.
- Terrains – Settings of terrains.
- Textures – Settings of textures.
In «Mesh select type» section Meshes, select how you want to define a model for the transformation:
- GameObjects – Objects to be added manually. For all the added objects considered subobjects. To avoid errors, you must remove all unnecessary sub-objects of the objects do not belong to the terrain.
- Layers – As models for the conversion of all the models used in the layer. In order to avoid errors from the layer to remove all unnecessary objects that do not belong to the terrain.
In «Direction», specify the direction of raytracing:
- Normal - Rays go from top to bottom.
- Reversed - Rays go from bottom to top. Must be used if the polygon model is facing downwards.
In «Y Range», select the desired range of heights:
- Minimal Range - the range of values will be determined automatically based on the meshes boundaries Y.
- Long Mesh Side - the range of values will be determined automatically based on the meshes boundaries by the maximum size of X and Z.
- Fixed Value - allows you to specify a Y range manually. The higher the value, the lower the accuracy.
In «Type» section Terrains, select:
- Exist Terrains - If you want to convert your existing terrains. To do this, place the terrains under the models and add terrains to the list.
- New Terrains - Terrains will be created and placed under the model automatically. In the appropriate fields number of the terrains that will be created.
If in «Type» section Terrains selected «New Terrains», then there are additional settings:
- Count - Number of terrains you want to get.
- Bounds - Type boundary of the model:
- Auto Detect – model boundaries are determined automatically.
- From GameObject – boundaries of model set by another GameObject. This GameObject must be Cube without rotation and include the entire area you want to convert.
- Select Bounds – you manually select the boundaries (like in Collider). Click «Show Selected», to start select the boundaries.
- New terrains settings.
If you want to use smoothing, choose the «Use smoothing of height maps» and set the smoothing factor.
Field «Holes» determines the behavior of Mesh to Terrain for areas of models where the height is unknown (holes and the edge of the model, if the model is not rectangular):
- Minimum Value - will use the minimum height.
- Neighbor Average - height will be calculated on the basis of the neighboring known values.
Press the «Start» and wait for the conversion. Depending on your computer system, the number of places and settings it can take from a few seconds to several minutes.
Important: If the model has a collider, other than «Mesh Collider», it can be converted incorrectly. To solve the problem, remove the collider component from models.
Convert from the context menu
In the «Hierarchy» right-click on the GameObject, you want to convert into terrain. Opens «Mesh to Terrain» with the selected GameObject.
Unity Terrains not support holes, but you can work around it.
Use «Holes» to determine the behavior of Mesh to Terrain for areas of models where the height is unknown (holes and the edge of the model, if the model is not rectangular).
If you want to make a holes, you can use third-party assets (Terrain Hole System or equivalent).
Working with Relief Terrain Pack
Relief Terrain Pack is not included with Mesh to Terrain package and by default its support is disabled.
Import Relief Terrain Pack to your project. Open Mesh to Terrain. Third-party / Enable Relief Terrain Pack.
No settings Relief Terrain Pack is required. If you have any questions about Relief Terrain Pack, you can find answers in the documentation of Relief Terrain Pack.
If you want to delete Relief Terrain Pack from the project, you should first disable it in Mesh to Terrain (Third-party / Disable Relief Terrain Pack).
If you forget to disable Relief Terrain Pack and removed it, then you will see errors in the console. To manually remove support of Relief Terrain Pack, open PlayerSettings (Edit / Project Settings / Player) and delete the corresponding entry from «Scripting Define Symbols».
In Unity Asset Store we ship only stable versions. Renewal period is several months.
Mesh to Terrain has a built-in update system, using which you can get early access to all versions and updates.
Click «Window / Infinity Code / Mesh to Terrain / Check Updates», to open window checking for updates. Enter your Invoice Number, select a channel of updates and click «Check New Versions».
If updates are available, you can read the list of changes and download the update.
If you have any problems with installing the update, then:
- Open an empty scene.
- Delete the folder «Infinity Code / Mesh to Terrain».
- Import the new asset version in the project.
After starting you get the error border or nothing happens.
There are two reasons for this:
- The models in the scene have a size that is insufficient for correct operation of physics. You need to increase the model in 100 + times and start the component again The problem is that the default scaling factor of imported models «0.01».
- You choose the models are not in the scene. Add model in the scene and convert them.
Terrains not correspond to the models axis Y.
- Scale up the model several times.
New terrains have a insufficient resolution / accuracy.
- Increase the Height Map Resolution.
- Increase the number of new terrains.
You can not see the grass or trees.
- Zoom in to the place where you draw grass or trees.
- Increase the value of «Tree Distance» in Terrain settings.
You receive an error «Selected meshes not in the scene», and the model is in the scene.
Please make sure that you choose a model from the tab «Scene».