CellVisualTransitionController Abstract Class

public abstract class CellVisualTransitionController : MonoBehaviour

Provides a base implementation for a Cell Visual Transition Controller.

A cell visual transition controller is responsible for controlling the visibility of a cell as it is added to the scene, removed from the scene, or transitioned from one LOD to another. For instance, you may wish to fade between different levels of detail to make the transition less apparent to the user, or have an object rise up/down as it they are added or removed from the scene.

Assuming the LOD the World Cells are coming from uses Chunks (either Terrain, Non Terrain Game Objects, or non Game Object based objects), each World Cell in the list contains a chunk array with references to the root chunk objects belonging to each cell (note, if not using multi chunking, this will just be a array with a single chunk).

How you display the objects belonging to your World Cell's is up to you, though typically if using Game Objects, the objects will contain a Renderer component that you can manipulate. You may have a single root object with no children, or the root objects may have many children. It is up to you to correctly transition all objects that should be visible.

Note that when Asset Chunks are stored in the Visible State, ImmediatelyTransitionToInvisibleState is called while the World Cell's the Asset Chunks belong to are still Deactivated in order to ensure they are in the proper Invisible State before Activation. In the same respect, after World Cell's have been Deactivated, ImmediatelyTransitionToVisibleState is called to place the Asset Chunks back in their starting Visible State, before sending them back to the Chunk Manager. This ensures the state of reused Asset Chunks and newly loaded Asset Chunks remains consistent. As a result of this behaviour you should keep the following points in mind:

1) Activating and/or Deactivating Asset Chunks within the Transition Controller method is generally a bad idea, as you may Activate an Asset Chunk that is not meant to be Activated. If you must Activate/Deactivate Asset Chunks, you should check to see if they are

Your chunk assets can either be stored (within your project hierarchy) in a visible or invisible visual state. Which option you choose is up to you, however you need to set the LOD setting (on your Streamable Grid asset) called Visual State Of Stored Assets When Active to the state you choose, and note the following:

If stored in a visible state, SAM needs to perform an extra step before detaching assets from cells as well as after attaching assets to cells. The former step is required to ensure assets passed to the Chunk Manager (which may be pooled) match the state of assets loaded by your Chunk Streamers. The ImmediatelyTransitionToVisibleStatemethod is used for this purpose. The latter step is needed to make the assets invisible before being activated and before the transition process begins. It does this by calling ImmediatelyTransitionToInvisibleState. Both methods may incur a performance penalty. If you notice a performance issue related to this, you can eliminate it by setting up your assets to be in an invisible state by default, and changing the setting on your Streamable Grid LOD to match. However, typically there is no issue and leaving your assets in the visible visual state is recommended for editing purposes (especially when that editing is done via the World Designer tool). Therefore, it is recommended to set your assets to the visual state, and only change them to the invisible state if you notice performance issues.

The nomenclature "visible" and "invisible" is used because in 99% of cases it accurately describes the state of the objects before and after the transition. With that said, it is not a requirement that your objects be actually "invisible" when in the Invisible State. This is a game specific implementation detail! However, in most instances the player will notice "popping in" of objects if they are not truly invisible when they are in the Invisible State.

By default any custom classes that you derive from this one will only work with LODs using ChunkType.Non_Terrain_Game_Object. To change this, you can enable or disable permissions by calling AllowChunkType and DisallowChunkType. When you allow a specific ChunkType, all LODs on a World Grouping that is using the transition controller and that are setup to use that Chunk Type, will have its World Cell's transitioned using the methods of the transition controller. You can also remove a permission for a Chunk Type by calling DisallowChunkType, which will stop World Cell's from LODs that use that Chunk Type from being transitioned.

Properties

Name Type Description
LODTransitionMakeInvisibleCurve AnimationCurve

Gets the correct Animation Curve that should be used to transition LOD Cells from Invisible to Visible according to the value of 'Use Alt Settings For LOD Transitions'.

Custom Transitioners can choose whether to use this curve or not.

LODTransitionMakeVisibleCurve AnimationCurve

Gets the correct Animation Curve that should be used to transition LOD Cells from Visible to Invisible according to the value of 'Use Alt Settings For LOD Transitions'.

Custom Transitioners can choose whether to use this curve or not.

LODTransitionTime float

The getter gets the transition time to use for LOD Transitions, according to the value of 'Use Alt Settings For LOD Transitions'.

The setter sets the LOD Transition Time setting (shown in the inspector), however this value will only be returned by the getter when 'Use Alt Settings For LOD Transitions' is true.

The total transition time is set at the beginning of each call to the TransitionBetweenLevelsOfDetail method, therefore adjustments to this value mid-game will only be applied the next time one of the methods is executed.

LODTransitionUpdateFrequency float

The getter gets the Update Frequency to use for LOD Transitions, which is the frequency (in seconds) at which changes in LOD Transitions will be updated. The value should be some factor smaller than the LOD Transition Time set.

The getter takes into account the current value of 'Use Alt Settings For LOD Transitions' in order to return the correct value.

The setter sets the LOD Update Frequency setting (shown in the inspector), however this value will only be returned by the getter when 'Use Alt Settings For LOD Transitions' is true.

When you set this value and 'Use Alt Settings For LOD Transitions' is true, the LODTransitionWaitPeriod object is updated to reflect the new value. Generally speaking, you will want to use the LODTransitionWaitPeriod object in your coroutine in order to yield, rather than getting the LODTransitionUpdateFrequency directly.

Larger values may result in better performance when transitioning a large number of objects, however will also result in jerkier motion.

LODTransitionWaitPeriod WaitForSeconds

Gets the WaitForSeconds object which is based on the LODTransitionUpdateFrequency (if 'Use Alt Settings For LOD Transitions' is true) or UpdateFrequency (if 'Use Alt Settings For LOD Transitions' is false). If the frequency is 0, this will return null, which will allow you to yield for a single frame.

You can yield return this object to have your transitioner pause execution for the update frequency time, effectively allowing you to control the frequency at which your transitioner updates the Cell Transitions during LOD Transitions.

MakeInvisibleCurve AnimationCurve

The Animation Curve defined in the inspector that can be used to transition the Cells from Visible to Invisible. Custom Transitioners can choose whether to use this curve or not.

MakeVisibleCurve AnimationCurve

The Animation Curve defined in the inspector that can be used to transition the Cells from Invisible to Visible. Custom Transitioners can choose whether to use this curve or not.

TransitionTime float

Gets or sets the the Transition Time set in the inspector (set should only be called in Play Mode or build). Your custom Transition Controller does not need to use this value, though it is usually easiest to make use of it.

The total transition time is set at the beginning of each method call, therefore adjustments to this value mid-game will only be applied the next time one of the methods is executed.

If 'Use Alt Settings For LOD Transitions' is false, this will change the Transition Time for all transitions, otherwise it will only effect non LOD transitions.

UpdateFrequency float

Gets or Sets the Update Frequency of transitions.

This is the frequency (in seconds) at which transition positions will be calculated. The value should be some factor smaller than the Transition Time set.

Larger values may result in better performance when transitioning a large number of objects, however will also result in jerkier motion.

When you set this value, the WaitPeriod object is updated to reflect the new value. Generally speaking, you will want to use the WaitPeriod object in your coroutine in order to yield, rather than getting the UpdateFrequency directly.

If 'Use Alt Settings For LOD Transitions' is false, this will change the Update Frequency for all transitions, otherwise it will only effect non LOD transitions.

UseAltSettingsForLODTransitions

Gets or sets whether to use alternative settings for LOD Transitions. This must return true in order to set the alternative LOD Transition properties.

WaitPeriod WaitForSeconds

Gets the WaitForSeconds object which is based on the UpdateFrequency. If the UpdateFrequency is 0, this will return null, which will allow you to yield for a single frame.

You can yield return this object to have your transitioner pause execution for the UpdateFrequency time, effectively allowing you to control the frequency at which your transitioner updates the Cell Transitions.

Methods

Awake()

protected void Awake()

The CellVisualTransitionController's Awake method, called by Unity. You cannot utilize Awake in your derived class. If you need to perform some sort of Awake related logic, override the AwakeExtended method, which will be called by this classes Awake method. Also note that you do not need to call base.AwakeExtended(); from your AwakeExtended method, as this is a virtual empty method that does nothing unless you override it. Also note that this method is protected simply so that if you derive from this class, you will see an error when trying to add the Awake method.


AwakeExtended()

protected virtual void AwakeExtended()

Can be overriden to implement custom Awake logic in your custom Controller. Needed because the base CellVisualTransitionController already makes use of Unity's Awake method.


CanWorldCellsBeTransitioned(ChunkType)

public abstract bool CanWorldCellsBeTransitioned(ChunkType ChunkType)

During Awake while the Application is playing, this method is queried for each asset Chunk Type in order to determine if World Cell's that use each Chunk Type can be transitioned using the Controller. You do not need to call this yourself, it is called automatically by SAM! The results of the queries are stored, so whatever values are first returned for each each Chunk Type will be used so long as the Controller is not unloaded.

You must override this method in your derived class. You can choose which Chunk Types are allowed by returning false for those you don't want to allow, and true for those you do. What value you return for each Chunk Type is up to you.

If transitioning between LODs and only one LOD group has a Chunk Type that can be transitioned, it will be transitioned via the TransitionToVisibleState or TransitionToInvisibleState methods instead of TransitionBetweenLevelsOfDetail.

This method may at times be used with the World Asset Editor. If you setup the allowable types to use at runtime (in Awake or Start), you must have some way to differentiate between an editor call and runtime call, and be able to return a valid answer to the method call in either case. Within the editor, you should always return true for Chunk Types that could be transitioned using your controller.

Parameters

Name Type Description
chunkType ChunkType

The Chunk Type you want to find out whether is able to be transitioned.

Returns

type
Should return true if World Cell's using Chunk Type can be transitioned, false otherwise. If false, World Cell's with that Chunk Type will not be transitioned using this controller, however you can change your settings later to allow that type to be used in the future.


ImmediatelyTransitionToVisibleState(ReadOnlyList<WorldCell>, ChunkType)

public abstract void ImmediatelyTransitionToVisibleState(ReadOnlyList<WorldCell> cells, ChunkType chunkType)

When overridden by a derived class, transitions one or more cells to the visible state in a single frame ("Visible" in this sense means that the visual representation of the objects contained within the cell should be made visible to the player).

This method should perform the same functions and result in the same Visible state for the cells as TransitionToVisibleState, the only difference being that it can only utilize a single frame and as such, it is not capable of creating transitional effects. That's okay, however, because this method is only used in situations where the World is being initialized in single/double frame mode, where the player should not see what is going on and transitional effects are not needed.

In addition to transitioning the World Cells' Asset Chunks visually, you can also place code that needs to be tightly coupled to the visibility of the Asset Chunks here. For instance, perhaps some interactive element needs to be enabled when the Asset Chunks are made visible. Such code can be placed here directly after the Asset Chunks are made visible.

Generally, it is good practice not to call SetActive(true) on any game objects associated with the cells and leave that responsibility up to SAM, World Asset Editor, or a World Grouping Listener component, however this is entirely up to you. If you decide to call SetActive in the method, ensure the method is the only thing calling SetActive to avoid unexpected behaviour (i.e., disable automatic chunk activation on your World component).

The list of cells are guaranteed to come from the same LOD and World Grouping. You can access the number of chunks a cell has via the NumChunks property. Access the chunks directly via the GetChunkBelongingToCell method, which takes a one based index as argument identifying the chunk you wish to retrieve (the first chunk is at index 1, second chunk at index 2, and so on). You should account for missing chunks by checking to make sure the chunks are not null, to allow the transitioner to be used with the World Asset Editor in cases where chunks have been manually deleted by the editor user.

Of course, if the LOD of these cells is set not to use chunks, the cell will not have chunks, in which case chunkType will equal ChunkType.None.

Note that unlike the other methods, there is no matching ImmediatelyTransitionToInvisibleState method. That is because single/double frame initialization does not have a matching single/double frame de-initialization. Put another way, TransitionToInvisibleState is ALWAYS used when unloading World Cells.

Parameters

Name Type Description
cells ReadOnlyList<WorldCell>

The list of cells whose chunks need to be transitioned to the "Visible" state.

chunkType ChunkType

The type of chunks (or none if they have none) that the input cells possess.


ResetToInvisibleState(ReadOnlyList<WorldCell>, ChunkType, bool)

public abstract void ResetToInvisibleState(ReadOnlyList<WorldCell> cells, ChunkType chunkType, bool isApplicationPlaying)

When overridden by a derived class, resets the state of the Asset Chunks belonging to the input World Cells to the Invisible Visual State.

Please note the differences between this method, TransitionToInvisibleState, and what happens to the transitionFromCells in TransitionBetweenLevelsOfDetail.

This method has the following characteristics:

1) The World Cells passed in may be Activated or Deactivated. Usually when isApplicationPlaying == true, the cells will be Deactivated.

2) Method CAN AND SHOULD manipulate properties to ensure state of Asset Chunks matches state of other Invisible Asset Chunks (Transform.position, opacity, etc.).

3) Because of characteristic 1, this method SHOULD NOT change the state of the World Cells or Asset Chunks.

4) Method should not run secondary logic, as usually logic is not needed by the World Designer tool, or if isApplicationPlaying is true, the logic should only be run when the Asset Chunks go from visible to invisible in the eyes of the player, which only occurs in TransitionToInvisibleState or TransitionBetweenLevelsOfDetail. TransitionToInvisibleState and TransitionBetweenLevelsOfDetail have the following characteristics:

1) The World Cells passed in (transitionFromCells for TransitionBetweenLevelsOfDetail) will ALWAYS be in an Activated State.

2) Methods SHOULD manipulate properties to make the Asset Chunks belonging to the World Cell's Invisible (Transform.position, opacity, etc.).

3) Methods may OPTIONALLY deactivate the Asset Chunks (via GameObject.SetActive(false) for instance) after the Asset Chunks have been made Invisible.

4) Secondary logic may be OPTIONALLY run that is tightly coupled to the visibility of the Asset Chunks (disabling interactability, for instance).

Generally speaking, while the application is playing this method is used on World Cells that are already deactivated and invisible to the Player, but whose Asset Chunk are stored in the Visible State. In order to ensure the state of the Asset Chunks matches the Invisible State expected by ImmediatelyTransitionToVisibleState, TransitionToVisibleState, and TransitionBetweenLevelsOfDetail (transitionToCells), some mechanism is required to modify the Asset Chunk properties to match other Invisible Asset Chunks. This method serves that purpose.

Outside of Play Mode within the Editor, the method is used by the World Designer tool for Asset Chunks that are stored in the Invisible Visual State. In such instances, the Asset Chunk state needs to be reset from Invisible to Visible and from Visible To Invisible at different points, in order to ensure the Assets can be seen in the editor while also ensuring that they can be saved in the proper state. Note that when the Asset Chunks are stored in the Visible Visual State, this resetting behaviour is not necessary, and as such, we recommended to store assets in the Visible Visual State, especially if notice issues with the loading/saving process in the World Designer tool and narrow down the issue to this method (or ResetToVisibleState).

You can differentiate between where the method is being used (while the application is playing or from the World Designer tool) using the isApplicationPlaying argument.

The list of cells are guaranteed to come from the same LOD and World Grouping. You can access the number of chunks a cell has via the NumChunks property. Access the chunks directly via the GetChunkBelongingToCell method, which takes a one based index as argument identifying the chunk you wish to retrieve (the first chunk is at index 1, second chunk at index 2, and so on). You should account for missing chunks by checking to make sure the chunks are not null, to allow the transitioner to be used with the World Asset Editor in cases where chunks have been manually deleted by the editor user.

If being used by the World Designer tool (isApplicationPlaying == false), it's possible that some of the Asset Chunks in one or more World Cells will be null. This is expected and should be accounted for. Null objects can simply be skipped.

Parameters

Name Type Description
cells ReadOnlyList<WorldCell>

The list of cells whose chunks need to be reset to the invisible state.

chunkType ChunkType

The type of chunks (or none if they have none) that the input cells possess.

isApplicationPlaying bool

Whether the Application is currently playing. This will be true if the game is running (i.e., Play Mode or within a normal built game), or false if the method is being called inside the Editor by the World Designer tool. You may need to execute slightly different code depending on whether the application is playing or not.

If false, you should account for the possibility of null Asset Chunks (which can simply be skipped).


ResetToVisibleState(ReadOnlyList<WorldCell>, ChunkType, bool)

public abstract void ResetToVisibleState(ReadOnlyList<WorldCell> cells, ChunkType chunkType, bool isApplicationPlaying)

When overridden by a derived class, resets the state of the Asset Chunks belonging to the input World Cells to the Visible Visual State.

Please note the differences between this method, ImmediatelyTransitionToVisibleState, TransitionToVisibleState, and what happens to the transitionToCells in TransitionBetweenLevelsOfDetail.

This method has the following characteristics:

1) The World Cells passed in may be Activated or Deactivated. Usually when isApplicationPlaying == true, the cells will be Deactivated. Whatever state the Cells are in, they should be left in that state! This method SHOULD NOT change the state of the World Cells or Asset Chunks.

2) This method CAN AND SHOULD manipulate properties to ensure state of Asset Chunks matches state of other Visible Asset Chunks (Transform.position, opacity, etc.).

3) This method SHOULD NOT run secondary logic, as usually logic is not needed by the World Designer tool, or if isApplicationPlaying is true, the logic should only be run when the Asset Chunks go from invisible to visible in the eyes of the player, which only occurs in ImmediatelyTransitionToVisibleState, TransitionToVisibleState or TransitionBetweenLevelsOfDetail. ImmediatelyTransitionToVisibleState, TransitionToInvisibleState and TransitionBetweenLevelsOfDetail have the following characteristics:

1) The World Cells passed in (transitionToCells for TransitionBetweenLevelsOfDetail) will either be in an Activated state, or you must immediately Activate their Asset Chunks (via GameObject.SetActive(true) for instance) before transitioning them to the Visible State (only if they aren't already Activated, which is controllable by you, the Developer!).

2) Methods SHOULD manipulate properties to make the Asset Chunks belonging to the World Cells Visible (Transform.position, opacity, etc.).

3) Secondary logic may be OPTIONALLY run that is tightly coupled to the visibility of the Asset Chunks (enabling interactability, for instance).

Generally speaking, while the application is playing this method is used on World Cells that use Asset Chunks stored in the Visible State. It is needed to get those chunks (which are transitioned to the Invisible State during the World Cells' deactivation) back to their stored Visible State. This is required so that if the Asset Chunks are re-used by the Chunk Manager, they are in the same Visible Stored State that newly loaded Asset Chunks (loaded via the Chunk Streamer) will be in. This ensures all Asset Chunks served by the Chunk Manager are always in the same state.

Outside of Play Mode within the Editor, the method is used by the World Designer tool for Asset Chunks that are stored in the Invisible Visual State. In such instances, the Asset Chunk state needs to be reset from Invisible to Visible and from Visible To Invisible at different points, in order to ensure the Assets can be seen in the editor while also ensuring that they can be saved in the proper state. Note that when the Asset Chunks are stored in the Visible Visual State, this resetting behaviour is not necessary, and as such, we recommended to store assets in the Visible Visual State, especially if you notice issues with the loading/saving process in the World Designer tool and narrow down the issue to this method (or ResetToInvisibleState).

You can differentiate between where the method is being used (while the application is playing or from the World Designer tool) using the isApplicationPlaying argument.

The list of cells are guaranteed to come from the same LOD and World Grouping. You can access the number of chunks a cell has via the NumChunks property. Access the chunks directly via the GetChunkBelongingToCell method, which takes a one based index as argument identifying the chunk you wish to retrieve (the first chunk is at index 1, second chunk at index 2, and so on). You should account for missing chunks by checking to make sure the chunks are not null, to allow the transitioner to be used with the World Asset Editor in cases where chunks have been manually deleted by the editor user.

If being used by the World Designer tool (isApplicationPlaying == false), it's possible that some of the Asset Chunks in one or more World Cells will be null. This is expected and should be accounted for. Null objects can simply be skipped.

Parameters

Name Type Description
cells ReadOnlyList<WorldCell>

The list of cells whose chunks need to be reset to the visible state.

chunkType ChunkType

The type of chunks (or none if they have none) that the input cells possess.

isApplicationPlaying bool

Whether the Application is currently playing. This will be true if the game is running (i.e., Play Mode or within a normal built game), or false if the method is being called inside the Editor by the World Designer tool. You may need to execute slightly different code depending on whether the application is playing or not.

If false, you should account for the possibility of null Asset Chunks (which can simply be skipped).


TransitionBetweenLevelsOfDetail(ReadOnlyList<WorldCell>, ChunkType, ReadOnlyList<WorldCell>, ChunkType)

public abstract IEnumerator<YieldInstruction> TransitionBetweenLevelsOfDetail(ReadOnlyList<WorldCell> transitionFrom, ChunkType transitionFromCellsChunkType, ReadOnlyList<WorldCell> transitionTo, ChunkType transitionToCellsChunkType)

When overridden by a derived class, transitions one or more cells between two levels of detail, so that the transitionTo cells are put into a visible state while the transtitionFrom cells are put into an invisible state. The list of cells are guaranteed to come from the same World Grouping. All transitionTo cells are also gauranteed to come from the same LOD, and all transitionFrom cells are guaranteed to come from the same LOD. "Visible/Invisible" in this sense means that the visual representation of the objects associated within the cell should be made visible/invisible to the player.

If you have setup your Chunk Type permissions to disallow some types, and one of the LODs to be transitioned to or from uses a disallowed type, while the other LOD uses an allowed type, this method will not be called. Instead, TransitionToVisibleState or TransitionToInvisibleState will be used, depending on whether the LOD with the allowed type is part of the transitionFrom group or transitionTo group.

Generally it is good practice not to call SetActive on any game objects associated with the cells and leave that responsibility up to SAM (by enabling Auto Activate Chunks When Adding Cells) or a World Grouping Listener component, however this is entirely up to you. If you decide to call SetActive in the method, ensure the method is the only thing calling SetActive to avoid unexpected behaviour.

You can access the number of chunks a cell has via the NumChunks property. Access the chunks directly via the GetChunkBelongingToCell method, which takes a one based index as argument identifying the chunk you wish to retrieve (the first chunk is at index 1, second chunk at index 2, and so on).

Of course, if the LOD of these cells is set not to use cekk objects, the cell will not have chunks.

Parameters

Name Type Description
transitionFromCells ReadOnlyList<WorldCell>

The list of cells containing the LOD chunks which are being transitioned from (i.e., they are what is currently visible that we want to make invisible). This list is read only and may contain cells from different LODs.

transitionFromCellsChunkType ChunkType

The type of chunks (or none if they have none) belonging to the transitionFromCells.

transitionToCells ReadOnlyList<WorldCell>

The list of cells containing the LOD chunks which are being transitioned to (i.e., they are what is currently invisible that we want to make visible). This list is read only and all cells are from the same World Grouping and LOD.

transitionToCellsChunkType ChunkType

The type of chunks (or none if they have none) belonging to the transitionToCells.

Returns

IEnumerator<YieldInstruction>
An IEnumerator<YieldInstruction> that can be iterated over or used as a coroutine. See the YieldInstruction page for more info.


TransitionToInvisibleState(ReadOnlyList<WorldCell>, ChunkType)

public abstract IEnumerator<YieldInstruction> TransitionToInvisibleState(ReadOnlyList<WorldCell> cells, ChunkType chunkType)

When overridden by a derived class, transitions one or more cells to the invisible state over one or more frames ("Invisible" in this sense means that the visual representation of the objects contained within the cell should be made invisible to the player).

In addition to transitioning the World Cells' Asset Chunks visually, you can also place code that needs to be tightly coupled to the visibility of the Asset Chunks here. For instance, perhaps some interactive element needs to be disabled when the Asset Chunks are made invisible. Such code can be placed here directly before the Asset Chunks are made invisible.

Generally, it is good practice not to call SetActive(false) on any game objects associated with the cells and leave that responsibility up to SAM, World Asset Editor, or a World Grouping Listener component, however this is entirely up to you. If you decide to call SetActive in the method, ensure the method is the only thing calling SetActive to avoid unexpected behaviour (i.e., disable automatic chunk deactivation on your World component).

The list of cells are guaranteed to come from the same LOD and World Grouping. You can access the number of chunks a cell has via the NumChunks property. Access the chunks directly via the GetChunkBelongingToCell method, which takes a one based index as argument identifying the chunk you wish to retrieve (the first chunk is at index 1, second chunk at index 2, and so on). You should account for missing chunks by checking to make sure the chunks are not null, to allow the transitioner to be used with the World Asset Editor in cases where chunks have been manually deleted by the editor user.

Of course, if the LOD of these cells is set not to use chunks, the cell will not have chunks, in which case chunkType will equal ChunkType.None.

Parameters

Name Type Description
cells ReadOnlyList<WorldCell>

The list of cells whose chunks need to be transitioned to the "Invisible" state.

chunkType ChunkType

The type of chunks (or none if they have none) that the input cells possess.

Returns

IEnumerator<YieldInstruction>
An IEnumerator<YieldInstruction> that can be iterated over or used as a coroutine. See the YieldInstruction page for more info.


TransitionToVisibleState(ReadOnlyList<WorldCell>, ChunkType)

public abstract IEnumerator<YieldInstruction> TransitionToVisibleState(ReadOnlyList<WorldCell> cells, ChunkType chunkType)

When overridden by a derived class, transitions one or more cells to the visible state over one or more frames ("Visible" in this sense means that the visual representation of the objects contained within the cell should be made visible to the player).

This method should perform the same functions and result in the same Visible state for the cells as ImmediatelyTransitionToVisibleState, the only difference being that it can take multiple frames in order to reach the state. This allows you to create transitional effects such as slowly changing the opacity of the Asset Chunks so they gradually become visible.

In addition to transitioning the World Cells' Asset Chunks visually, you can also place code that needs to be tightly coupled to the visibility of the Asset Chunks here. For instance, perhaps some interactive element needs to be enabled when the Asset Chunks are made visible. Such code can be placed here directly after the Asset Chunks are made visible.

Generally, it is good practice not to call SetActive(true) on any game objects associated with the cells and leave that responsibility up to SAM, World Asset Editor, or a World Grouping Listener component, however this is entirely up to you. If you decide to call SetActive in the method, ensure the method is the only thing calling SetActive to avoid unexpected behaviour (i.e., disable automatic chunk activation on your World component).

The list of cells are guaranteed to come from the same LOD and World Grouping. You can access the number of chunks a cell has via the NumChunks property. Access the chunks directly via the GetChunkBelongingToCell method, which takes a one based index as argument identifying the chunk you wish to retrieve (the first chunk is at index 1, second chunk at index 2, and so on). You should account for missing chunks by checking to make sure the chunks are not null, to allow the transitioner to be used with the World Asset Editor in cases where chunks have been manually deleted by the editor user.

Of course, if the LOD of these cells is set not to use chunks, the cell will not have chunks, in which case chunkType will equal ChunkType.None.

Parameters

Name Type Description
cells ReadOnlyList<WorldCell>

The list of cells whose chunks need to be transitioned to the "Visible" state.

chunkType ChunkType

The type of chunks (or none if they have none) that the input cells possess.

Returns

IEnumerator<YieldInstruction>
An IEnumerator<YieldInstruction> that can be iterated over or used as a coroutine. See the YieldInstruction page for more info.