public sealed class StreamableGrid : ScriptableObject
Each Streamable Grid represents a collection of Stremable Cells, and more importantly,
the
Streamable Asset Chunks associated with those Cells.
It stores vital information about the Cells, such as their dimensions and whether
each Cell
has Asset Chunks associated with it (and if they do, how many Asset Chunks are used
by it),
and vital information about those Chunks, such as the shared name of all Asset Chunks
in the
group and their level of detail.
You can think of a Streamable Grid as a blueprint for building
World's at runtime (Worlds combines multiple Streamable Grid's
and actual scene positional space to form a physical game world).
To create a Streamable Grid asset, right click the folder where you'd like to create
it and choose
"Create -> Deep Space Labs -> SAM -> Streamable Grid".
All of the public methods that take in or return a Cell
are 1 based. This means the first
Cell on the Streamable Grid has a row of 1, column of 1, and (for 3D worlds) a layer
of 1.
If you see PreInitSafe in the name of one of the methods or properties below, it means
that the
method or property can be called before the Streamable Grid has been initialized (at
runtime or
in editor code). Methods or properties without PreInitSafe should only be called after
the
Streamable Grid has been intialized (which only happens when the game is run).
Name | Type | Description |
---|---|---|
Axes_PreInitSafe | Axes |
Gets the Axes used by the Streamable Grid |
CellEqualityComparer | EqualityComparer<Cell> |
Gets an Cell equality comparer matching the type of Streamable Grid (2D or 3D).
|
ColumnWidthsNative | NativeArray<double> |
Gets the column widths of the Streamable Grid as a native array. The widths are only configured once the Streamable Grid has been initialized. The lifetime of this array is handled by the Streamable Grid, so you should never dispose it yourself. You should also treat it as a read only array and not reassign values to any of its indexes, otherwise you will screw things up royally since SAM uses these arrays internally. Finally, note that the length of the array will be 1 if all columns are of equal size (in an attempt to save space). |
ColumnsAsLong | long |
Gets the number of columns on the Streamable Grid as a long. |
Columns_PreInitSafe | int |
Gets the number of columns on the Streamable Grid. |
EnabledCells | long |
Gets the total number of enabled cells on this Streamable Grid. |
FlattenCellIndex | Func<Cell, long> |
A function that can be retrieved and used to flatten a Streamable Grid Cell Index.
|
FlattenCellIndexForSparseEnabledArray | Func<Cell, int> |
A function that can be retrieved and used to flatten the Cell Index of an Enabled
Cell on the Streamable Grid, where the input Cell is
one based.
|
FlattenCellIndex_ZeroBased | Func<Cell, long> |
Works just like
FlattenCellIndex,
except the input Streamable Grid Cell should be zero based.
|
FlattenEnabledCellIndexForSparseEnabledArray_ZeroBased | Func<Cell, int> |
Works just like
FlattenCellIndexForSparseEnabledArray,
except the input Streamable Grid Cell should be zero based.
|
Height | double |
Gets the height of the Streamable Grid, which is the distance between the beginning of the first layer and end of the last layer. |
IsCellDisabled | Func<Cell, bool> |
Gets (post initialization only)/Sets (PreInitSafe) a function that can be used to
determine if a particular cell on the Streamable Grid is disabled.
|
IsGrid3D | bool |
Gets a value indicating whether the Streamable Grid is 3D (Axes Type set to Three
Dimensional).
|
IsInitialized | bool |
Gets a value indicating if the Streamable Grid is initialized. It should go without saying, but this property can be accessed before the Grid has been intialized (in which case it will return false). |
LayerHeightsNative | NativeArray<double> |
Gets the layer heights of the Streamable Grid as a native array. The heights are only configured once the Streamable Grid has been initialized. The lifetime of this array is handled by the Streamable Grid, so you should never dispose it yourself. You should also treat it as a read only array and not reassign values to any of its indexes, otherwise you will screw things up royally since SAM uses these arrays internally. Finally, note that the length of the array will be 1 if all layers are of equal size (in an attempt to save space), or if the Streamable Grid is 2D. |
Layers | int |
Gets the number of layers on the Streamable Grid. Will be 1 if the Axes is not Three Dimensional. |
LayersAsLong | long |
Gets the number of layers on the Streamable Grid as a long. |
Length | double |
Gets the length of the Streamable Grid, which is the distance between the beginning of the first row and end of the last row. |
LevelsOfDetail_PreInitSafe | int |
Gets the number of LOD Groups on the Streamable Grid (effectively the levels of detail
the Grid makes use of).
|
RowLengthsNative | NativeArray<double> |
Gets the row lengths of the Streamable Grid as a native array. The lengths are only configured once the Streamable Grid has been initialized. The lifetime of this array is handled by the Streamable Grid, so you should never dispose it yourself. You should also treat it as a read only array and not reassign values to any of its indexes, otherwise you will screw things up royally since SAM uses these arrays internally. Finally, note that the length of the array will be 1 if all rows are of equal size (in an attempt to save space). |
RowsAsLong | long |
Gets the number of rows on the Streamable Grid as a long. |
Rows_PreInitSafe | int |
Gets the number of rows on the Streamable Grid. |
ToOneBasedCell | Func<Cell, Cell> |
Gets a function that can be used to convert a cell in zero based format to a cell in one based format. This method is especially useful for processing large amounts of cells, as it will disregard the layer value if the Streamable Grid is not 3D (will always be 1 on the returned Cell). |
ToZeroBasedCell | Func<Cell, Cell> |
Gets a function that can be used to convert a cell in one based format to a cell in zero based format. This method is especially useful for processing large amounts of cells, as it will disregard the layer value if the Streamable Grid is not 3D (will always be 0 on the returned Cell). |
Width | double |
Gets the width of the Streamable Grid, which is the distance between the beginning of the first column and end of the last column. |
Deregisters with the World and if no more users are registered, de-initialized the World (disposes of Native Containers used by the Streamable Grid at runtime).
public static long CalculateTotalCells(int rows, int columns, int layers)
Calculates the total number of cells given rows, columns, and layers values. The input values are casted to long before the calculation is performed, allowing the total number of cells to be as large as 18,446,744,073,709,551,615. This method does not detect overflow, if overflow occurs the returned value will likely be negative and invalid. If using this method with input values retrieved from a Streamable Grid, however, you do not need to worry about overflow, as the Streamable Grid can only contain rows/columns/layers values that do not overflow.
Name | Type | Description |
---|---|---|
rows | int |
The number of rows to use in the calculation. |
columns | int |
The number of columns to use in the calculation. |
layers | int |
The number of layers to use in the calculation. |
long
The total number of cells.
public static long CalculateTotalCellsWithOverflowCheck(int rows, int columns, int layers)
Calculates the total number of cells given rows, columns, and layers values. The input values are casted to long before the calculation is performed, allowing the total number of cells to be as large as 18,446,744,073,709,551,615. This method will detect and throw an overflow exception if the total number of cells is greater than this value!
Name | Type | Description |
---|---|---|
rows | int |
The number of rows to use in the calculation. |
columns | int |
The number of columns to use in the calculation. |
layers | int |
The number of layers to use in the calculation. |
long
The total number of cells.
Type | Condition |
---|---|
OverflowException | Thrown if the calculated value is greater than 18,446,744,073,709,551,615 |
public Cell ConvertCellOnEndlessGridToCellOnStreamableGrid(Cell cellOnEndlessGrid)
Converts an Endless Grid Cell to its equivalent Streamable Grid Cell. Each Endless
Grid Cell is just a projection of a Streamable Grid Cell, and thus has the same dimensions
and chunk associations.
Note that the passed in cell should be 1 based. That is, the first cell in the grid
has a row of 1, column of 1,
and layer of 1. The returned Streamable Grid Cell will also be 1 based.
Use this method over the PreInitSafe version if you know the Streamable Grid is initialized,
as it will be slightly faster.
Name | Type | Description |
---|---|---|
cellOnEndlessGrid | Cell |
The Endless Grid Cell to be converted. |
Cell
The equivalent Streamable Grid Cell for the Endless Grid Cell specified.
public Cell ConvertCellOnEndlessGridToCellOnStreamableGrid_PreInitSafe(Cell cellOnEndlessGrid)
Converts a cell on the Endless Grid to a cell on the Streamable Grid. You can use this method before the Streamable Grid has been initialized.
Name | Type | Description |
---|---|---|
cellOnEndlessGrid | Cell |
The one based cell on the Endless Grid you wish to convert |
Cell
The converted one based cell on the Streamable Grid.
public int ConvertEndlessGridColumnToStreamableGridColumn_PreInitSafe(int endlessGridColumn)
Converts an Endless Grid column to a column on the Streamable Grid. You can use this method before the Streamable Grid has been initialized.
Name | Type | Description |
---|---|---|
endlessGridColumn | int |
The Endless Grid column to convert. |
int
The column on the Streamable Grid.
public int ConvertEndlessGridLayerToStreamableGridLayer_PreInitSafe(int endlessGridLayer)
Converts an Endless Grid layer to a layer on the Streamable Grid. You can use this method before the Streamable Grid has been initialized.
Name | Type | Description |
---|---|---|
endlessGridLayer | int |
The Endless Grid layer to convert. |
int
The layer on the Streamable Grid.
public int ConvertEndlessGridRowToStreamableGridRow_PreInitSafe(int endlessGridRow)
Converts an Endless Grid row to a row on the Streamable Grid. You can use this method before the Streamable Grid has been initialized.
Name | Type | Description |
---|---|---|
endlessGridRow | int |
The Endless Grid row to convert. |
int
The row on the Streamable Grid.
public EnabledStreamableGridEnumerable EnabledStreamableGridCells()
Gets an enumerable collection of the enabled cells on this Streamable Grid. This can
be used in a foreach statement to iterate over
only enabled cells in the grid in a garbage free manner, and automatically takes into
account whether the grid is 2D or 3D. This is very useful in situations where
you need to perform some operation that uses a Cell struct, for each enabled cell
on the Streamable Grid. If you have a very large world with a ton of cells where
most are disabled, it can make more sense to use this rather than iterating over every
cell on the Streamable Grid via
StreamableGridCells_PreInitSafe.
Also note that in some cases, it may be beneficial to iterate over the flattened index
of each enabled cell rather than the index in
Cell form, for example if you want to retrieve the number of chunks used by a cell, you
can use
the flattened index rather than the Cell with the
GetCellChunksUsingArrayIndex
method, which is more efficient. To iterate over the flattened indexes of enabled
cells,
use FlattenedIndexesOfEnabledCells.
EnabledStreamableGridEnumerable
The enumerable collection of enabled Streamable Grid Cells.
Example:
class IterateOverEnabledStreamableGridCellsExample { StreamableGrid streamableGrid; public void Iterate() { foreach(Cell enabledCell in streamableGrid.EnabledStreamableGridCells()) DoSomething(enabledCell); } }
public int FindEndlessGridColumnAndPositionPointIsIn(double point, int originCellColumn, double originCellColumnPosition, out double columnPosition)
Finds the Endless Grid column and scene position of the column that a point in world
space falls within. Use
FindEndlessGridColumnPointIsIn
if you don't care about the position of the column. If you want to know the displacement
of the column from the input originCellColumnPosition, use
FindEndlessGridColumnPointIsIn (alt).
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
point | double |
The point that will be used to find the Endless Grid column. |
originCellColumn | int |
The Origin Cell column of your World. |
originCellColumnPosition | double |
The Origin Cell column position of your World. |
columnPosition | double |
The scene position of the column (set after method runs). |
int
The Endless Grid column that the point is in.
public int FindEndlessGridColumnPointIsIn(double point, int originCellColumn, double originCellColumnPosition)
Finds the Endless Grid column that a point in world space falls within. Use
FindEndlessGridColumnAndPositionPointIsIn
if you need the scene space position of the column, or
FindEndlessGridColumnPointIsIn (alt) if you need the columns displacement from the originCellColumnPosition.
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
point | double |
The point that will be used to find the Endless Grid column. |
originCellColumn | int |
The Origin Cell column of your World. |
originCellColumnPosition | double |
The Origin Cell column position of your World. |
int
The Endless Grid column that the point is in.
public int FindEndlessGridColumnPointIsIn(double point, int originCellColumn, double originCellColumnPosition, out double columnDistanceFromOrigin)
Finds the Endless Grid column that a point in world space falls within. Use
FindEndlessGridColumnAndPositionPointIsIn
if you need the scene space position of the column, or
FindEndlessGridColumnPointIsIn
if you only need the column without any position data.
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
point | double |
The point that will be used to find the Endless Grid column. |
originCellColumn | int |
The Origin Cell column of your World. |
originCellColumnPosition | double |
The Origin Cell column position of your World. |
columnDisplacementFromOrigin | double |
An additional out parameter that meausres the displacement of the found Endless Grid column to the Origin Cell's column. |
int
The Endless Grid column that the point is in.
public int FindEndlessGridLayerAndPositionPointIsIn(double point, int originCellLayer, double originCellLayerPosition, out double layerPosition)
Finds the Endless Grid layer and scene position of the layer that a point in world
space falls within. Use
FindEndlessGridLayerPointIsIn
if you don't care about the position of the layer. If you want to know the displacement
of the layer from the input originCellLayerPosition, use
FindEndlessGridLayerPointIsIn (alt).
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
point | double |
The point that will be used to find the Endless Grid layer. |
originCellLayer | int |
The Origin Cell layer of your World. |
originCellLayerPosition | double |
The Origin Cell layer position of your World. |
layerPosition | double |
The scene position of the layer. |
int
The Endless Grid layer that the point is in.
public int FindEndlessGridLayerPointIsIn(double point, int originCellLayer, double originCellLayerPosition)
Finds the Endless Grid layer that a point in world space falls within. Use
FindEndlessGridLayerAndPositionPointIsIn
if you need the scene space position of the layer, or
FindEndlessGridLayerPointIsIn (alt) if you need the layer displacement from the originCellLayerPosition.
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
point | double |
The point that will be used to find the Endless Grid layer. |
originCellLayer | int |
The Origin Cell layer of your World. |
originCellLayerPosition | double |
The Origin Cell layer position of your World. |
int
The Endless Grid layer that the point is in.
public int FindEndlessGridLayerPointIsIn(double point, int originCellLayer, double originCellLayerPosition, out double layerDistanceFromOrigin)
Finds the Endless Grid layer that a point in world space falls within. Use
FindEndlessGridLayerAndPositionPointIsIn
if you need the scene space position of the layer, or
FindEndlessGridLayerPointIsIn
if you only need the layer without any position data.
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
point | double |
The point that will be used to find the Endless Grid layer. |
originCellLayer | int |
The Origin Cell layer of your World. |
originCellLayerPosition | double |
The Origin Cell layer position of your World. |
layerDisplacementFromOrigin | double |
An additional out parameter that meausres the displacement of the found Endless Grid layer to the Origin Cell's layer. (Ex: if found cell is above the origin, displacement will be positive, if below it will be negative). |
int
The Endless Grid layer that the point is in.
public int FindEndlessGridRowAndPositionPointIsIn(double point, int originCellRow, double originCellRowPosition, out double rowPosition)
Finds the Endless Grid row and scene position of the row that a point in world space
falls within. Use
FindEndlessGridRowPointIsIn
if you don't care about the position of the layer. If you want to know the displacement
of the row from the input originCellRowPosition, use
FindEndlessGridRowPointIsIn (alt).
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
point | double |
The point that will be used to find the Endless Grid row. |
originCellRow | int |
The Origin Cell row of your World. |
originCellRowPosition | double |
The Origin Cell row position of your World. |
rowPosition | double |
An additional out parameter that tells you the scene position of the row. |
int
The Endless Grid row that the point is in.
public int FindEndlessGridRowPointIsIn(double point, int originCellRow, double originCellRowPosition)
Finds the Endless Grid row that a point in world space falls within. Use
FindEndlessGridRowAndPositionPointIsIn
if you need the scene space position of the row, or
FindEndlessGridRowPointIsIn (alt) if you need the row displacement from the originCellRowPosition.
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
point | double |
The point that will be used to find the Endless Grid row. |
originCellRow | int |
The Origin Cell row of your World. |
originCellRowPosition | double |
The Origin Cell row position of your World. |
int
The Endless Grid row that the point is in.
public int FindEndlessGridRowPointIsIn(double point, int originCellRow, double originCellRowPosition, out double rowDistanceFromOrigin)
Finds the Endless Grid row that a point in world space falls within. Use
FindEndlessGridRowAndPositionPointIsIn
if you need the scene space position of the row, or
FindEndlessGridRowPointIsIn
if you only need the row without any position data.
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
point | double |
The point that will be used to find the Endless Grid row. |
originCellRow | int |
The Origin Cell row of your World. |
originCellRowPosition | double |
The Origin Cell row position of your World. |
rowDisplacementFromOrigin | double |
An additional out parameter that meausres the displacement of the found Endless Grid row to the Origin Cell's row. |
int
The Endless Grid row that the point is in.
public FlattenedIndexesOfEnabledCellsEnumerable FlattenedIndexesOfEnabledCells()
Gets an enumerable collection of the flattened indexes of enabled cells on this Streamable
Grid. This can be used in a foreach statement to iterate over
only the enabled cells in the grid in a garbage free manner, and automatically takes
into account whether the grid is 2D or 3D.
This is very useful in situations where you need to perform some operation that uses
the Flattened Index of each enabled cell on the Streamable Grid.
If you have a very large world with a ton of cells where
most are disabled, it can make more sense to use this rather than iterating over every
cell and checking whether each one is enabled or disabled.
For each enabled cell, the flattened index is equivalent to the value returned by
the
FlattenCellIndex function for that cell (not the
FlattenEnabledCellIndex function!).
The number of items in the collection will always be equal to EnabledCells. If you need
to iterate over this collection repeatedly over different frames, it may make sense
to store the values in an array, using EnabledCells as the
length of the array.
FlattenedEnabledStreamableGridIndexesEnumerable
The enumerable collection of the flattened indexes of Streamable Grid Cells that are
enabled.
Example:
class IterateOverFlattenedIndexesOfEnabledCellsExample { StreamableGrid streamableGrid; public void Iterate() { Data[] enabledCellData = new Data[streamableGrid.EnabledCells]; int i = 0; foreach(int flattenedIndex in streamableGrid.FlattenedIndexesOfEnabledCells)) enabledCellData[i++] = GetCellData(flattenedIndex); } }
public CellDimensions GetCellDimensionsOfStreamableGridCell(Cell streamableGridCell)
Get the cell dimensions of cell on the Streamable Grid. The indexes of this cell must
fall within the range
of rows, columns, and/or layers of your Streamable Grid.
For instance, in a 4 rows x 4 columns Streamable Grid, a row or column index of
0 or 5 would not be valid (but 1, 2, 3, or 4 would be).
Name | Type | Description |
---|---|---|
streamableGridCell | Cell |
The cell on the Streamable Grid whose dimensions should be retrieved. |
CellDimensions
The cell dimensions of the cell.
public CellDimensions GetCellDimensionsOfStreamableGridCell_PreInitSafe(Cell streamableGridCell)
Gets the dimensions of a specific cell on the Streamable Grid. Safe for use before Streamable Grid has been initialized (for example, in the editor).
Name | Type | Description |
---|---|---|
streamableGridCell | Cell |
The cell on the Streamable Grid to get the dimensions for |
CellDimensions
The cell's dimensions
public long GetCountOfEnabledCells_PreInitSafe()
Gets a count of the total Enabled Cells on this Streamable Grid. Safe to use before or after the Streamable Grid has been initialized, although if you know for sure that the Grid has been initialized, using the EnabledCells property will be marginally faster.
long
The number of Enabled Cells.
public double GetHeightOfEndlessGridLayer(int endlessGridLayer)
Get the height of an Endless Grid layer. Each input Endless Grid layer is translated
to its equivalent Streamable Grid layer, and then the height of that Streamable Grid
layer is returned.
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
endlessGridLayer | double |
The layer who's height should be retrieved. |
double
The height of the input endlessGridLayer.
public double GetHeightOfStreamableGridLayer(int streamableGridLayer)
Get the height of a Streamable Grid layer. The input streamableGridLayer should be
0 index based. For instance, to get the
height of the very first layer
in the grid, you would pass in 0, not 1. To get the second layer, you'd pass in 1,
not 2, and so on.
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
streamableGridLayer | double |
The layer who's height should be retrieved. |
double
The height of the input streamableGridLayer.
public GridLODDetails GetLODDetails(int LOD)
Returns the grid LOD details for the given LOD. All LOD Group specific data can be retrieved from the GridLODDetails object.
Name | Type | Description |
---|---|---|
LOD | int |
The LOD. |
GridLODDetails
The grid LOD details for the LOD.
Type | Condition |
---|---|
NullReferenceException | thrown if the LOD is less than 1 or greater than the number of levels of detail on this Streamable Grid. |
public int GetChunksOfStreamableGridCell_PreInitSafe(int LOD, Cell streamableGridCell)
Gets the number of chunks the cellOnStreamableGrid has in the LOD group specified by the LOD index.
Name | Type | Description |
---|---|---|
LOD | index |
The index of the LOD as shown in the inspector. |
streamableGridCell | Cell |
The cell on the Streamable Grid. |
int
The number of chunks.
public double GetLengthOfEndlessGridRow(int endlessGridRow)
Get the length of an Endless Grid row. Each input Endless Grid row is translated
to its equivalent Streamable Grid row, and then the length of that Streamable Grid
row is returned.
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
endlessGridRow | double |
The row who's length should be retrieved. |
double
The length of the input endlessGridRow.
public double GetLengthOfStreamableGridRow(int streamableGridRow)
Get the length of a Streamable Grid row. The input streamableGridRow should be 0 index
based.
For instance, to get the length of the very first row
in the grid, you would pass in 0, not 1. To get the second row, you'd pass in 1, not
2, and so on.
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
streamableGridRow | double |
The row who's length should be retrieved. |
double
The length of the input streamableGridRow.
public Vector3Double GetPositionOfEndlessGridCell(Cell endlessGridCell, Cell originCell, Vector3Double originCellPosition)
Gets the position of an Endless Grid Cell in world space. Because the Streamable Grid
knows nothing about
world space, you must pass in the Origin Cell and Origin Cell position of your world
for this to work.
It is recommended to use the inidivual get position methods (GetPositionOfEndlessGridColumn,
etc.) if you
are getting the position frequently, as those methods are slightly more performant.
Name | Type | Description |
---|---|---|
endlessGridCell | Cell |
The Endless Grid Cell whose position will be found. |
originCell | Cell |
The Origin Cell of your world. Usually will be (1, 1, 1), unless your world is set to stay centered around the origin. |
originCellPosition | Vector3Double |
The position of the Origin Cell of your world. This should simply be the origin of your world. |
Vector3Double
The position of the Endless Grid Cell.
public double GetPositionOfEndlessGridColumn(int endlessGridColumn, int originCellColumn, double originCellColumnPosition))
Gets the position of a column on a theoretically Endless Grid. Note that the Streamable
Grid knows nothing about
positioning in World Space, so for this method to work you you must pass in the Current
origin
cell column of your world and
the position of that Origin Cell column. If using this with a World component, the
Origin Cell column can be queried
via the World's OriginCell property, while the position can be queried via the OriginColumnPosition
property.
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
endlessGridColumn | int |
The column whose position you wish to get. |
originCellColumn | int |
The Origin Cell column of your World. |
originCellColumnPosition | double |
The Origin Cell column position of your World. |
flaot
The position of the Endless Grid column.
public double GetPositionOfEndlessGridLayer(int endlessGridLayer, int originCellLayer, double originCellLayerPosition)
Gets the position of a layer on a theoretically Endless Grid. Note that the Streamable
Grid knows nothing about
positioning in World Space, so for this method to work you you must pass in the Current
Origin Cell layer of your world and
the position of that Origin Cell layer. If using this with a World component, the
Origin Cell layer can be queried
via the World's OriginCell property, while the position can be queried via the OriginLayerPosition
property.
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
endlessGridLayer | int |
The layer whose position you wish to get. |
originCellLayer | int |
The Origin Cell layer of your World. |
originCellLayerPosition | double |
The Origin Cell layer position of your World. |
double
The position of the Endless Grid layer.
public double GetPositionOfEndlessGridRow(int endlessGridRow, int originCellRow, double originCellRowPosition)
Gets the position of a row on a theoretically Endless Grid. Note that the Streamable
Grid knows nothing about
positioning in World Space, so for this method to work you you must pass in the Current
Origin Cell row of your world and
the position of that Origin Cell row. If using this with a World component, the Origin
Cell row can be queried
via the World's OriginCell property, while the position can be queried via the OriginRowPosition
property.
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
endlessGridRow | int |
The row whose position you wish to get. |
originCellRow | int |
The Origin Cell row of your World. |
originCellRowPosition | double |
The Origin Cell row position of your World. |
flaot
The position of the Endless Grid row.
public CellDimensions GetVectorDimensionsOfStreamableGridCell_PreInitSafe(Cell streamableGridCell)
Gets the dimensions of a specific cell on the Streamable Grid. Safe for use before
Streamable Grid has
been initialized (for example, in the editor).
This method is similar to
GetCellDimensionsOfStreamableGridCell_PreInitSafe, however the dimensions are placed
on the correct axes according
to the Streamable Grid's Axes. For example, if the Axes is 2D XZ or 3D, the row length
of the cell is placed
in the z component of the Vector3Double and the layer height is placed in the y component.
If the Axes is 2D XY, the row length is placed in the y component instead, and the
layer height is placed in the
z component.
Name | Type | Description |
---|---|---|
streamableGridCell | Cell |
The cell on the Streamable Grid to get the dimensions for |
Vector3Double
The cell's dimensions as a Vector3Double. This method automatically takes into account
the Axes and places
the cell's dimensions on the correct axes.
public double GetWidthOfEndlessGridColumn(int endlessGridColumn)
Get the width of an Endless Grid column. Each input Endless Grid column is translated
to its equivalent Streamable Grid column, and then the width of that Streamable Grid
column is returned.
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
endlessGridColumn | double |
The column who's width should be retrieved. |
double
The width of the input endlessGridColumn.
public double GetWidthOfStreamableGridColumn(int streamableGridColumn)
Get the width of a Streamable Grid column. The input streamableGridColumn should be
0 index based.
For instance, to get the width of the very first column
in the grid, you would pass in 0, not 1. To get the second column, you'd pass in 1,
not 2, and so on.
This is a runtime method and should not be used in the editor.
Name | Type | Description |
---|---|---|
streamableGridColumn | double |
The column who's width should be retrieved. |
double
The width of the input streamableGridColumn.
public bool IsCellDisabled_PreInitSafe(Cell streamableGridCell)
Can be used to determine if a particular Streamable Cell on this grid is disabled. Uses the states of the cells as set in the inspector of the Streamable Grid. At runtime it is better to use the IsCellDisabled function, as it will be faster.
Name | Type | Description |
---|---|---|
streamableGridCell | Cell |
The Streamable Grid Cell you wish to know the state of. |
bool
True if the Cell is disabled, false otherwise.
public StreamableGridEnumerable StreamableGridCells_PreInitSafe()
Gets an enumerable collection of the cells on this Streamable Grid. This can be used
in a foreach statement to iterate over
every cell in the grid in a garbage free manner, and automatically takes into account
whether the grid is 2D or 3D.
This is very useful in situations where
you need to perform some operation that uses a Cell struct, for each cell on the Streamable
Grid. Note that the enumerable does not take into account
disabled cell locations, which may or may not be a problem.
If you have a very large world with many disabled cells, you should consider using
the
EnabledStreamableGridCells_PreInitSafe method instead.
StreamableGridEnumerable
The enumerable collection of Streamable Grid Cells
Example:
class IterateOverStreamableGridCellsExample { StreamableGrid streamableGrid; public void Iterate() { foreach(Cell cell in streamableGrid.StreamableGridCells_PreInitSafe()) DoSomething(cell); } }
public bool TryGetGlobalExtraData_PreInitSafe(string key, out string data)
Attemps to get data stored in the Streamable Grids Global Extra Data. Use this if you know for certain the data you want is stored in the Global Extra Data. If you are not sure if it's stored here, or you know it is but there also may be data with the same key stored in an LOD's Extra Data, use the GridLODDetails TryGetExtraData_PreInitSafe method istead, as that will return the data from the LOD if it exist, or data from the Global Extra Data if it does not exist on the LOD.
Name | Type | Description |
---|---|---|
key | string |
The key to use to access the data. |
data | string |
Will be set to the data if the method returns true or null if the method returns false. |
bool
True if the data was successfully retrieved, false otherwise.