In Unity Editor
There’re 3 ways to add Terrain Grid System to the scene in Editor time:
-
If you’re using Terrain Grid System for 2D (not terrain based) select the menu GameObject -> 3D Object -> Terrain Grid System and the grid will be added to the scene.
-
If you wish to add a grid to a Terrain or other gameobjects like mesh-based terrains, just select your terrain or root of gameobjects and add the script “Terrain Grid System”. It will configure automatically for you.
-
Alternatively, you can drag the prefab “TerrainGridSystem” from “Resources/Prefabs” folder to your scene and assign your terrain or gameobject to the Terrain property.
Once created, select the GameObject created to show custom properties and assign the terrain gameobject reference.
At runtime
You can also add Terrain Grid System dynamically in Play Mode in 2 ways:
-
Call AddTerrainGridSystem() method on your terrain or gameobject. Example:
TerrainGridSystem tgs = myTerrainGameObject.AddTerrainGridSystem();
Where myTerrainGameObject is the gameobject where your terrain is or any other gameobject is you use mesh-based terrain.
-
Or instantiate the “TerrainGridSystem” prefab from “Resources/Prefabs” and call SetTerrain(your terrain gameobject) form script.