MatPropBlockTransitioner Abstract Class

public sealed class MatPropBlockTransitioner : 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 + material property blocks, or a custom shader that makes use of a float that can be set using a material property block.

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 the root chunk and its children, grandchildren, etc., so long as those objects contain a Renderer component. Also note that the material property block is applied at the Renderer level, meaning it is applied to all Materials on the Renderer that use the specified shader property.

If you only want a specific Material to be affected, 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 entire World update.

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 PerMaterialTransitioner is very subtle. The PerMaterialTransitioner should generally only be used with the Scriptable Render Pipeline batcher, in situations where you are using the same shader variant with many different meshes/materials. If not using the SRP or you are using many instances of the same mesh and material, you will probably be better off using this transitioner. You can easily test with each transitioner to see which one is more performant.

Methods

AwakeExtended()

protected sealed override void AwakeExtended()

Override of AwakeExtended


CanWorldCellsBeTransitioned(ChunkType)

public sealed override bool CanWorldCellsBeTransitioned(ChunkType ChunkType)

Queries the Mat Prop Block 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)

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)

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 transitioned to a "deactivated" state. "Deactivated" in this sense just means the chunks should be made invisible to the player (assuming the cell is not being culled by your culling system [if present]). All cells are part of the same World Grouping and LOD.

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>

The list of cells whose chunks need to be transitioned to an "activated" state. "Activated" in this sense just means the chunks should be made visible to the player (assuming the cell is not being culled by your culling system [if present]). All cells are part of the same World Grouping and LOD.

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.