public class WorldCellWithTerrain : WorldCell
Represents a WorldCell with a single Unity Terrain Asset Chunk. This type is created
automatically in place of the base World Cell class when
a World Cell's active LOD is associated with an LOD Group that uses the Unity Terrain
Chunk Type.
While there are some methods available in this class, we generally advise not calling
these methods yourself, as SAM automates
Terrain Neighboring so that calling the methods is not necessary.
You may have a need to access the Terrain component of the World Cell however, from
a custom World Grouping Listener, for instance. In that case,
you can access the Terrain via the Terrain property.
Name | Type | Description |
---|---|---|
Terrain | Terrain |
Gets the Terrain associted with this WorldCellWithTerrain. |
public void ClearNeighborsAndTerrain()
Calls Terrain.SetNeighbors(null, null, null, null) and sets the internal terrain reference
of this World
Cell to null.
Generally speaking, the Streamable Asset Manager will call this method automatically
at the
appropriate time; you shouldn't need to call it yourself and should only do so if
you absolutely
understand the consequences and know what you are doing!
public Terrain GetTerrainIfPartOfSameTerrainGroup(WorldCell worldCell)
Checks the input World Cell to see if it is a WorldCellWithTerrain and part of the
same Terrain Group (meaning
they have the same Grouping ID) as this WorldCellWithTerrain.
If it is,
this method returns the Terrain associated with it, otherwise it returns null.
You can use this for ease of checking
if two World Cells that neighbor each other have Terrain from the same group, as you
can just pass in the neighbor of
the cell by using the EastNeighbor, WestNeighbor, etc. properties.
If you just want to get the terrain of another cell (or neighbor) on the same World
Grouping of this cell, and
don't care whether it is part of the same
terrain group as this cell, you can cast the neighbor to a WorldCellWithTerrain using
the
WorldCellWithTerrain cellWithTerrain = cell as WorldCellWithTerrain line of code.
Then check if the
cellWithTerrain value is null. If is not, the cell should have a terrain, though do
note that if it is a
newly loaded cell, it may not have a terrain yet, depending on when you perform this
check. Please check
the
WorldGroupingListener
page for more information!
Name | Type | Description |
---|---|---|
worldCell | WorldCell |
The WorldCell that might or might not be part of the same terrain group as this WorldCellWithTerrain. |
Terrain
The terrain if the cell is part of the same terrain group (meaning they have the same
Grouping ID). If the input cell is null or not a WorldCellWithTerrain, this
method will return null.
public bool IsPartOfSameTerrainGroup(WorldCell worldCell)
Checks the input World Cell to see if it is part of the same Terrain Group as this
WorldCellWithTerrain.
If it is, this method returns true, otherwise it returns false. You can use this for
ease of
checking if two World Cells that neighbor each other have Terrain from the same group,
as you can
just pass in the neighbor of the cell by using the EastNeighbor, WestNeighbor, etc.
properties.
If you need the actual terrain associated with the World Cell, use
GetTerrainIfPartOfSameTerrainGroup
instead, as it performs the same check (thus, calling it after this
method would add redundancy).
If you just want to know whether a neighbor has a terrain and don't care whether it
is part of the same
terrain group as this cell, you can cast the neighbor to a WorldCellWithTerrain using
the
WorldCellWithTerrain cellWithTerrain = cell as WorldCellWithTerrain line of code.
Then check if the
cellWithTerrain value is null. If is not, the cell should have a terrain, though do
note that if it is a
newly loaded cell, it may not have a terrain yet, depending on when you perform this
check.
Name | Type | Description |
---|---|---|
worldCell | WorldCell |
The WorldCell that might or might not be part of the same terrain group as this WorldCellWithTerrain. |
bool
True if the cell is part of the same terrain group. If the input cell is null or not
a WorldCellWithTerrain, this
method will return false. Additionally, the cells must have the same grouping ID or
the method will return false.
public void ResetNeighbors()
Checks each World Cell Neighbor of this World Cell and gets a terrain for each if the neighbor is a valid terrain neighbor. Then calls Terrain.SetNeighbors using each terrain neighbor as input. Generally speaking, the Streamable Asset Manager will call this method automatically at the appropriate time; you shouldn't need to call it yourself and should only do so if you absolutely understand the consequences and know what you are doing!