StreamableGrid Class

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).

Properties

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).

This can be used with dictionaries and other classes that utilaize Equality Comparers.

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.

Flattening treats the Streamable Grid as if it were a 2D or 3D multidimensional array, and then converts a Streamable Grid Cell index to a 0 based index that can be used in a 1D array.

Note that the input Streamable Grid Cell index should be 1 based, so that the first row is Row = 1, first column is Column = 1, and first layer is Layer = 1. In this scenario, the index would be flattend to 0.

You can use this index in a 1D array to store per Streamable Grid Cell data, however if you have a very large world with a large number of disabled cells, you would be better off using a sparse array that only stores data for enabled cells. You can use FlattenCellIndexForSparseEnabledArray for that purpose instead of this method (alternatively, you could also use a dictionary that uses the non flattened Streamable Grid Cell Index as key).

Note that the returned value is a long, however if it exceeds the max value of an int, the returned value will not be suitable to be used as an array 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.

Flattening treats the Streamable Grid as if it were a 2D or 3D multidimensional array, and then converts the enabled Streamable Grid Cell index to a 0 based index that can be used in a 1D array.

The difference between this function and FlattenCellIndex is that this function takes into account the enabled/disabled cell state of all cells, allowing it to be used with a sparse array which stores data only for enabled cells. However, you must ensure that the cell is enabled before using it, as errors will arise if it is not!

Example: Say you have a 2 x 2 2D Streamable Grid with 3 enabled cells and 1 disabled cell (at Row = 2, Column = 1, or index 2 in a 1D array).

A normal array storing data for all cells would look like this: [1-1, 1-2, 2-1, 2-2], where 2-1 is the disabled cell. If you wanted to find the index of cell 2-2 within this array, you would use FlattenCellIndex(new Cell(2,2)), which would return a value of 3.

A sparse array storing data only for enabled cells would look like this: [1-1, 1-2, 2-2]. As you can see, the data for cell 1-1 and 1-2 are still in the correct position, however data for 2-2 is now at index 2 rather than 3, because cell 2-1 has been removed from the array. In order to retrieve the correct index of 2, you would need to use FlattenEnabledCellIndex_SparseEnabledArray(new Cell(2,2)).

Do note that this function is more expensive to use than FlattenCellIndex, so you should be cautious about using it alot in a single frame (however, profile to find out whether it's truly an issue!)

Because the value is intended to be used as an index into an array, it is an int. If the number of enabled cells exceeds 2,147,483,647 issues will arise!

Note that the input Streamable Grid Cell index should be 1 based, so that the first row on the Streamable Grid is Row = 1, first column is Column = 1, and first layer is Layer = 1.

FlattenCellIndex_ZeroBased Func<Cell, long>

Works just like FlattenCellIndex, except the input Streamable Grid Cell should be zero based.

This means the first row on the Streamable Grid is Row = 0, first column is Column = 0, and first layer is Layer = 0.

FlattenEnabledCellIndexForSparseEnabledArray_ZeroBased Func<Cell, int>

Works just like FlattenCellIndexForSparseEnabledArray, except the input Streamable Grid Cell should be zero based.

This means the first row on the Streamable Grid is Row = 0, first column is Column = 0, and first layer is Layer = 0.

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.

When no function is manually assigned, at initialization the function is configured to return a value based on how the cell states are configured in the Unity Editor (via the visual grid or World Designer tool), however for very large worlds or especially for procedural worlds, the information about which cells are disabled can either be too large or may even be unconfigurable (for instance, the information for procedural worlds might only be known at runtime!).

In these situations, you can assign a custom function. When doing so, it is recommended to either enable or disable all cells on your Streamable Grid (in the insepctor or via the World Designer Tool) to save on memory, unless you plan on setting this property to null in the future (which will cause the Grid to revert back to the editor configured enabled/disabled settings, so you'll want them to remain accurate).

Setting this property before the Streamable Grid is initialized is allowed, however you cannot use the function to try and determine if a cell is disabled until after the Grid is intialized (i.e., you should not get the property until after initialization), unless of course you have set it to a custom function already.

If you need to find out whether a cell is disabled before the Grid is initialized (such as in editor code), use the IsCellDisabled_PreInitSafe method instead.

However, if you know that the Grid has been initialized, you should use this property/function as it will be faster.

IsGrid3D bool

Gets a value indicating whether the Streamable Grid is 3D (Axes Type set to Three Dimensional).

If you need this info befor ethe Grid is intialized, use the Axes_PreInitSafe property and check if it's 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).

Remember that just because a Grid has an LOD Group, it does not mean that the LOD Group will be used. You still need an Active Grid with a Loading Blueprint that makes use of the LOD Group, a World Region that contains Cells associated with the LOD Group, or a script that adds users for Cells associated with the LOD Group.

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.

Methods

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).


CalculateTotalCells(int, int, int)

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.

Parameters

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.

Returns

long
The total number of cells.


CalculateTotalCellsWithOverflowCheck(int, int, int)

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!

Parameters

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.

Returns

long
The total number of cells.

Exceptions

Type Condition
OverflowException Thrown if the calculated value is greater than 18,446,744,073,709,551,615

ConvertCellOnEndlessGridToCellOnStreamableGrid(Cell)

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.

Parameters

Name Type Description
cellOnEndlessGrid Cell

The Endless Grid Cell to be converted.

Returns

Cell
The equivalent Streamable Grid Cell for the Endless Grid Cell specified.


ConvertCellOnEndlessGridToCellOnStreamableGrid_PreInitSafe(Cell)

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.

Parameters

Name Type Description
cellOnEndlessGrid Cell

The one based cell on the Endless Grid you wish to convert

Returns

Cell
The converted one based cell on the Streamable Grid.


ConvertEndlessGridColumnToStreamableGridColumn_PreInitSafe(int)

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.

Parameters

Name Type Description
endlessGridColumn int

The Endless Grid column to convert.

Returns

int
The column on the Streamable Grid.


ConvertEndlessGridLayerToStreamableGridLayer_PreInitSafe(int)

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.

Parameters

Name Type Description
endlessGridLayer int

The Endless Grid layer to convert.

Returns

int
The layer on the Streamable Grid.


ConvertEndlessGridRowToStreamableGridRow_PreInitSafe(int)

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.

Parameters

Name Type Description
endlessGridRow int

The Endless Grid row to convert.

Returns

int
The row on the Streamable Grid.


EnabledStreamableGridCells()

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.

Returns

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);
                }
            }
            

FindEndlessGridColumnAndPositionPointIsIn(double, int, double, out double)

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.

Parameters

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).

Returns

int
The Endless Grid column that the point is in.


FindEndlessGridColumnPointIsIn(double, int, double)

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.

Parameters

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.

Returns

int
The Endless Grid column that the point is in.


FindEndlessGridColumnPointIsIn(double, int, double, out double)

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.

Parameters

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.

Returns

int
The Endless Grid column that the point is in.


FindEndlessGridLayerAndPositionPointIsIn(double, int, double, out double)

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.

Parameters

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.

Returns

int
The Endless Grid layer that the point is in.


FindEndlessGridLayerPointIsIn(double, int, double)

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.

Parameters

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.

Returns

int
The Endless Grid layer that the point is in.


FindEndlessGridLayerPointIsIn(double, int, double, out double)

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.

Parameters

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).

Returns

int
The Endless Grid layer that the point is in.


FindEndlessGridRowAndPositionPointIsIn(double, int, double, out double)

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.

Parameters

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.

Returns

int
The Endless Grid row that the point is in.


FindEndlessGridRowPointIsIn(double, int, double)

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.

Parameters

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.

Returns

int
The Endless Grid row that the point is in.


FindEndlessGridRowPointIsIn(double, int, double, out double)

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.

Parameters

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.

Returns

int
The Endless Grid row that the point is in.


FlattenedEnabledStreamableGridIndexes()

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.

Returns

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);
                }
            }
            

GetCellDimensionsOfStreamableGridCell(Cell)

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).

Parameters

Name Type Description
streamableGridCell Cell

The cell on the Streamable Grid whose dimensions should be retrieved.

Returns

CellDimensions
The cell dimensions of the cell.


GetCellDimensionsOfStreamableGridCell_PreInitSafe(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).

Parameters

Name Type Description
streamableGridCell Cell

The cell on the Streamable Grid to get the dimensions for

Returns

CellDimensions
The cell's dimensions


GetCountOfEnabledCells_PreInitSafe()

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.

Returns

long
The number of Enabled Cells.


GetHeightOfEndlessGridLayer(int)

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.

Parameters

Name Type Description
endlessGridLayer double

The layer who's height should be retrieved.

Returns

double
The height of the input endlessGridLayer.


GetHeightOfStreamableGridLayer(int)

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.

Parameters

Name Type Description
streamableGridLayer double

The layer who's height should be retrieved.

Returns

double
The height of the input streamableGridLayer.


GetLODDetails(int)

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.

Parameters

Name Type Description
LOD int

The LOD.

Returns

GridLODDetails
The grid LOD details for the LOD.

Exceptions

Type Condition
NullReferenceException thrown if the LOD is less than 1 or greater than the number of levels of detail on this Streamable Grid.

GetChunksOfStreamableGridCell_PreInitSafe(int, Cell)

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.

Parameters

Name Type Description
LOD index

The index of the LOD as shown in the inspector.

streamableGridCell Cell

The cell on the Streamable Grid.

Returns

int
The number of chunks.


GetLengthOfEndlessGridRow(int)

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.

Parameters

Name Type Description
endlessGridRow double

The row who's length should be retrieved.

Returns

double
The length of the input endlessGridRow.


GetLengthOfStreamableGridRow(int)

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.

Parameters

Name Type Description
streamableGridRow double

The row who's length should be retrieved.

Returns

double
The length of the input streamableGridRow.


GetPositionOfEndlessGridCell(Cell, Cell, Vector3Double)

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.

Parameters

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.

Returns

Vector3Double
The position of the Endless Grid Cell.


GetPositionOfEndlessGridColumn(int, int, double)

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.

Parameters

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.

Returns

flaot
The position of the Endless Grid column.


GetPositionOfEndlessGridLayer(int, int, double)

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.

Parameters

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.

Returns

double
The position of the Endless Grid layer.


GetPositionOfEndlessGridRow(int, int, double)

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.

Parameters

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.

Returns

flaot
The position of the Endless Grid row.


GetVectorDimensionsOfStreamableGridCell_PreInitSafe(Cell)

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.

Parameters

Name Type Description
streamableGridCell Cell

The cell on the Streamable Grid to get the dimensions for

Returns

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.


GetWidthOfEndlessGridColumn(int)

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.

Parameters

Name Type Description
endlessGridColumn double

The column who's width should be retrieved.

Returns

double
The width of the input endlessGridColumn.


GetWidthOfStreamableGridColumn(int)

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.

Parameters

Name Type Description
streamableGridColumn double

The column who's width should be retrieved.

Returns

double
The width of the input streamableGridColumn.


IsCellDisabled_PreInitSafe(Cell)

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.

Parameters

Name Type Description
streamableGridCell Cell

The Streamable Grid Cell you wish to know the state of.

Returns

bool
True if the Cell is disabled, false otherwise.


StreamableGridCells_PreInitSafe()

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.

Returns

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);
                }
            }
            

TryGetGlobalExtraData_PreInitSafe(string, out string)

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.

Parameters

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.

Returns

bool
True if the data was successfully retrieved, false otherwise.