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.

GetColumnWidthFunction Func<int, double>

Gets a function that can be used to get the width of a particular column (the input) on this Streamable Grid. Configured after the Streamable Grid is initialized.

GetLayerHeightFunction Func<int, double>

Gets a function that can be used to get the height of a particular layer (the input) on this Streamable Grid. Configured after the Streamable Grid is initialized.

GetRowLengthFunction Func<int, double>

Gets a function that can be used to get the length of a particular row (the input) on this Streamable Grid. Configured after the Streamable Grid is initialized.

GridDimensions Vector3Double

Gets the dimensions of the Streamable Grid expressed as a Vector3Double. This can be useful in math operations. The components of the vector are automatically set correctly according to the Axes of the Grid.

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.

Indices Cell

Gets the number of Rows, Columns, and Layers expressed as a Cell structure.

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

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.


DeRegister()

public void DeRegister()

Deregisters with the World and if no more users are registered, de-initializes the World (disposes of Native Containers used by the Streamable Grid at runtime).

The World cannot be reinitialized because the arrays used to create the native arrays are cleared at runtime (to save on memory). So, once user count becomes 0, the World should never be registered with another user.

Note, in practice it should never be necessary for you to call this method manually; it is done automatically by SAM! The only time you might need to do so is if you are using the Streamable Grid for some sort of custom purpose. Every De-Register call must have been proceeded by a Register call previously!


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, which you can do using the FlattenedIndexesOfEnabledCells method.

Finally, take heed that this method can only be used after the Streamable Grid has been initialized. If you need to a method that will work before the Grid is intialized, for example outside of Play Mode in the editor, use EnabledStreamableGridCells_PreInitSafe instead.

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

EnabledStreamableGridCells_PreInitSafe()

public EnabledCellsEnumerable_PreInitSafe EnabledStreamableGridCells_PreInitSafe()

Same as EnabledStreamableGridCells, except this method can be used even if the Streamable Grid has not be initialized, for example in the editor outside of Play Mode.

Returns

EnabledCellsEnumerable_PreInitSafe
The enumerable collection of enabled Streamable Grid Cells.

Example:

            class IterateOverEnabledStreamableGridCellsExample
            {
                StreamableGrid streamableGrid;
                
                public void Iterate()
                {
                    foreach(Cell enabledCell in streamableGrid.EnabledStreamableGridCells_PreInitSafe())
                        DoSomething(enabledCell);
                }
            }
            

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 (as set in the Unity Editor). 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. If you have set a custom IsCellDisabled function, note that this value will not be accurate, as there is no way to count the number of enabled cells in that case.


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_PreInitSafe(int)

public GridLODDetails GetLODDetails_PreInitSafe(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 (one based).

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.


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.


Register()

public void Register()

Registers with the Streamable Grid. This initializes the Grid if no other users have already registered with it, and must be used if you wish to access members that are only available after the Grid has been initialized, such as the native arrays.

Note that SAM automatically calls this method when the Streamable Grid is used with any World (even if it's just a prototype), so the chances of you needing to call it yourself are slim. The only time that might not be true is if you are using the Streamable Grid for some custom purpose, and it is not being used with any Worlds in the scene.

For each call to Register, you must call DeRegister! This method should also not be called in the editor outside of Play Mode!


SetGlobalExtraData_PreInitSafe(string, string)

public void SetGlobalExtraData_PreInitSafe(string key, string data)

Sets the global extra data for a given key.

This will replace any existing data using the key for this Streamable Grid, or create a new entry if there is no existing entry using the key.

Generally speaking, you should call this method before SAM has been initialized in order to ensure that anything making use of the Extra Data will have the correct value, as most things making use of it will retrieve the extra data just once (when SAM is initialized) and cache the value for performance reasons.

If you want to set/change the extra data for a specific LOD Group, you should use the GridLODDetail class's SetExtraData_PreInitSafe method instead.

Parameters

Name Type Description
key string

The key used to set the extra data.

data string

The data to set.


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.