PerMaterialTransitioner Abstract Class

public sealed class PerMaterialTransitioner : CellVisualTransitionController

A custom implementation of a Cell Visual Transition Controller. Please take a look at that page before continuing, as it provides an overview of what this class is responsible for.

This particular transition controller requires either a shader compatible with Unity's built-in LODGroup component, or a custom shader that makes use of a float. In either case, the shader should usually be compatible with the SRP batcher as well.

It works by performing the transition over a fixed time period, where the float in the shader (or built in lod crossfade vector value if using 'Use Unity Crossfade') is set to a value between 0 (at start) and 1 (at end) for cells transitioning to a "visible" state, and to a value between 1 (at start) and 0 (at end) for cells transitioning to an "invisible" state. It is up to your shader to determine how this float property is used, for instance by implementing true transparency or using alpha clipping (dithering).

This transitioner will perform a separate transition for every child, grandchild, etc. of each root chunk, so long as that child contains a Renderer component. It also transitions every Material on each Renderer, so if that is not your desired behaviour, you will need to create a custom Transitioner.

There is a special optimization that is performed when a renderer is not in view of the camera, whereby the renderer is immediately set to its final state (either visible or invisible). This results in only renderers in view of the player being transitioned, which speeds up the transition process, which in turn speeds up the dyanmic loading process. The Renderer.IsVisible property is used to determine if a renderer is visible to any cameras. Within the editor, the Scene View camera counts as a camera in this capacity, so if a game object visible in your scene view but not in the game view, you will still notice it being transitioned.

The difference between this component and the MatPropBlockTransitioner is very subtle.

This one should generally only be used with the Scriptable Render Pipeline, in situations where you are using the same shader with many different meshes and want to use the SRP Batcher.

If not using the SRP or you are using many instances of the same mesh and material, you will probably be better off using the MatPropBlockTransitioner. You can easily test with each transitioner to see which one is more performant.

Note that if 'Use Shared Material' is disabled, static runtime batching (using the StaticBatcherListener or some other method) cannot be used on the same Renderers that will be transitioned using this controller.

Methods

AwakeExtended()

protected sealed override void AwakeExtended()

Override of AwakeExtended


CanWorldCellsBeTransitioned(ChunkType)

public sealed override bool CanWorldCellsBeTransitioned(ChunkType ChunkType)

Queries the Transitioner to determine if World Cell's using the Chunk Type specified can be transitioned at the present time.

Parameters

Name Type Description
chunkType ChunkType

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

Returns

type
Always returns true if the Chunk Type is Non_Terrain_Game_Object. Also returns true if the Chunk Type is Unity_Terrain and Allow Use With Terrain is enabled in the inspector. Otherwise returns false.


ImmediatelyTransitionToVisibleState(ReadOnlyList<WorldCell>, ChunkType)

public sealed override void ImmediatelyTransitionToVisibleState(ReadOnlyList<WorldCell> cells, ChunkType chunkType, bool isApplicationPlaying)

Please take a look at the description for the ImmediatelyTransitionToActivatedState method on the CellVisualTransitionController Base Class before continuing, as this description outlines all that you need to know regarding this method.

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 sealed override void ResetToInvisibleState(ReadOnlyList<WorldCell> cells, ChunkType chunkType, bool isApplicationPlaying)

Please take a look at the description for the ResetToInvisibleState method on the CellVisualTransitionController Base Class before continuing, as this description outlines all that you need to know regarding this method.

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.


ResetToVisibleState(ReadOnlyList<WorldCell>, ChunkType, bool)

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

Please take a look at the description for the ResetToVisibleState method on the CellVisualTransitionController Base Class before continuing, as this description outlines all that you need to know regarding this method.

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.


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

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

Please take a look at the description for the TransitionBetweenLevelsOfDetail method on the CellVisualTransitionController Base Class before continuing, as this description outlines all that you need to know regarding this method. If you are trying to understand how the Mat Prop Block Transitioner works, please take a look at the class summary.

Parameters

Name Type Description
transitionFrom ReadOnlyList<WorldCell>

The list of cells containing the LOD chunks which are being transitioned from (i.e., they are what is currently activated that we want to deactivate). 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 transitionFrom World Cells.

transitionTo ReadOnlyList<WorldCell>

The list of cells containing the LOD chunks which are being transitioned to (i.e., they are what is currently deactivated that we want to activate). 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 transitionTo World Cells.

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 sealed override IEnumerator<YieldInstruction> TransitionToInvisibleState(ReadOnlyList<WorldCell> cells, ChunkType chunkType)

Please take a look at the description for the TransitionToDeactivatedState method on the CellVisualTransitionController Base Class before continuing, as this description outlines all that you need to know regarding this method. If you are trying to understand how the Mat Prop Block Transitioner works, please take a look at the class summary.

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.

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 sealed override IEnumerator<YieldInstruction> TransitionToVisibleState(ReadOnlyList<WorldCell> cells, ChunkType chunkType)

Please take a look at the description for the TransitionToActivatedState method on the CellVisualTransitionController Base Class before continuing, as this description outlines all that you need to know regarding this method. If you are trying to understand how the Mat Prop Block Transitioner works, please take a look at the class summary.

Parameters

Name Type Description
cells ReadOnlyList<WorldCell>

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

Returns

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