Give Page Feedback | API

Cell Visual Transition Controllers - Overview

Cell Visual Transition Controllers were created to give you complete control over how Asset Chunks transition into/out of the scene, as well as how they transition between different Levels of Detail. While usually the transitions will consist of cross fading or some other transparency driven process, there is nothing stopping you from manipulating the Asset Chunks' positions, scales, and other properties in order to perform the transitions.

There are four default Transition Controllers included with the SAM, the Mat Prop Block Transitioner, Per Material Transitioner, PositionTransitioner, and ScaleTransitioner. You can learn about these Transitioners in their dedicated Sections in this Chapter.

Unlike other Customizable Components, it is very likely that you will wish to create a Custom Transition Controller. There is also a dedicated Section in this Chapter which will help you do that.

How Do They Work?

Because Transition Controllers need to be able to transition World Cells from one LOD to another, they operate at the World Grouping level. Since each World Grouping may contain different types of Asset Chunks, each Grouping is able to use a unique Transition Controller (though this is not required; you may use the same Transition Controller with multiple World Groupings if you wish).

The Controllers method's operate on batches of World Cells where each batch is guaranteed to contain World Cells from the same World Grouping and using the same LOD. The primary methods use the IEnumerator return type which allows their execution to be carried out over multiple frames (if you wish), which is usually necessary in order to create nice looking transition effects.

Asset Chunk Visibility

At any given time, Asset Chunks can be in the Visible State, Invisible State, or some mix of the two (which is technically always guaranteed to be visible). The primary job of the transition controller is to transition them between these two states in a way that is not noticeable to the player, or when that is impossible, at least in a pleasing way.

For Game Object Asset Chunks, a distinction between the Active/Deactivate State and Visible/Invisible State needs to be made.

Active/Deactive refers to the Game Object's Unity State while Visible/Invisible refers to whether the Player would be able to see the Asset Chunks while they are in an Activated State.

A Deactivated Game Object in the Visible State would obviously not be visible to the player, however we still refer to it being in the Visible State, if upon Activation it would be visible to the player.

Within your project, Asset Chunks can either be stored in the Visible or Invisible State, and which state they are stored in needs to be set via the LOD Group they belong to (on the Streamable Grid asset).

When Assets are stored in the Visible State, in order not to be seen by the Player upon load, they need to be loaded in a Deactivated state. If using Prefabs this can be done by the Prefab Chunk Streamers automatically when they load the Assets, however for other Asset Types (such as Scenes), you will need to store the assets in a Deactivated state. Upon being loaded the World resets them to the Invisible State, so that later when they are Activated they will not be seen by the Player (these resets are carried out using the single frame ResetToInvisibleState method).

For Asset Chunks stored in the Invisible State, it is not necessary for them to be loaded in a Deactivated State, since they are already invisible to the player. While this may make storing Asset Chunks in an Invisible State more appealing, unfortunately Asset Chunks stored in this State do not always function well with the World Designer tool. As such, it is recommended to store your Asset Chunks in the Visible State.

Activation/Deactivation

While Transition Controllers can be used to activate/deactivate Game Object based Asset Chunks, it is usually a better idea to let the World handle activation/deactivation automatically.

However, if you wish to take over the activation/deactivation within a Custom Transition Controller, you should disable the Auto Activate Chunks When Adding Cells and/or Auto Deactivate Chunks When Removing Cells options (note, these settings exist universally at the World level, at the World Grouping level, or at the LOD level via LOD Overrides).

If you leave these options enabled, Asset Chunks are activated just before they are transitioned from Invisible to Visible. They are deactivated just after being transitioned from Visible to Invisible. When activating/deactivating them manually, you should adhere to this ordering.

Note that you should never activate/deactivate Asset Chunks in the ResetToVisibleState or ResetToInvisibleState methods. These methods should only manipulate the properties (Transform.position, transparency, etc.) that control the Visual State of the Asset Chunks.

Secondary Visibility Based Logic

Sometimes, there is secondary logic that needs to be run when the Asset Chunks become visible or invisible (for example, enabling/disabling interactability). Generally speaking, we recommend putting such logic in World Grouping Listeners, however if you have logic that needs to be very tightly coupled with the change in visibility of the Asset Chunks, you can put such logic in the Transition methods.

Do keep in mind that usually, this logic would not also be placed inside the Reset methods, as that would cause the logic to cancel itself out in several situations. The only time you might want to run secondary logic inside the Reset methods is when the methods are used with the World Designer tool and you need that secondary logic to run even outside of Play Mode. In such situations, you an use the isApplicationPlaying (which will be false when the World Designer tool is calling the Reset methods) to find out if the secondary logic needs to run.

Otherwise, secondary logic should only be run inside of the ImmediatelyTransitionToVisibleState, TransitionToVisibleState, TransitionToInvisibleState, and TransitionBetweenLevelsOfDetail methods.

Assigning Transition Controllers

These components can be assigned to specific World Groupings on the World Component, via the Cell Visual Transition Controller field within each Grouping's Optional Components window.

Only one Transition Controller can be assigned to each World Grouping, and you can use the same Controller or different controllers for each Grouping.

Default Settings/Properties

The base Cell Visual Transition Controller class has some default settings/properties which you can edit in the inspector and use when creating custom Transition Controllers. All build-in Transition Controllers use these settings, however their use is completely optional in your own custom Controllers. They include:

1) TransitionTime - The total time transitions should take. You can use this as a starting value if you wish rather than an absolute value. For instance, the PositionTransitioner and ScaleTransitioner contain an additional deviation setting that allows the transition time of each transform to be randomly offset by a small value.

2) UpdateFrequency - Can be used directly or indirectly (via WaitPeriod) to control the frequency at which your Transition Controller runs. By default this value is always set to 0, and if not changed, this will result in the controller being run once per frame.

3) WaitPeriod - This is a WaitForSeconds yield instruction that is set based on UpdateFrequency (and updated each time UpdateFrequency is changed). You can yield return it in your custom transition methods, which will cause that method to pause execution for the amount of time dictated by UpdateFrequency. Will be null if UpdateFrequency is set to 0.

4) MakeVisibleCurve - An animation curve which can be used (via the Evaluate method) to translate the time of the transition (between 0 and 1) to a value (which usually falls between 0 and 1). Typically, at t = 0, the value returned would be 0 while at t = 1, the value would be 1 (to simulate a transition from invisible to visible). The in-between values can be adjusted using the curve to change the transition to linear, quadratic, or any other curve type.

4) MakeInvisibleCurve - An animation curve which can be used (via the Evaluate method) to translate the time of the transition (between 0 and 1) to a value (which usually falls between 0 and 1). Typically, at t = 0, the value returned would be 1 while at t = 1, the value would be 0 (to simulate a transition from visible to invisible). The in-between values can be adjusted using the curve to change the transition to linear, quadratic, or any other curve type.

What If I Don't Want To Use A Transition Controller?

Using a Transition Controller is completely optional, however if not using them, make sure that when your Asset Chunks are activated, they are in a Visible State that the player can see! Not using a Transition Controller can be beneficial as transitioning usually takes some time, resulting in slower World updates. As such, it can make sense to not use Transition Controllers for things that can be activated/deactivated without the player noticing. For example, if you have a top down game and your World Cells are only loaded/unloaded outside the view of the Camera, it generally will not make sense to perform transitions.