Skip to main content

Preview StatsComponent

To see how changes to a Stat can affect the whole system, you can use a Preview StatsComponent.

A Preview StatsComponent is a copy of your StatsComponent that you can modify, then discard or validate the changes.

Create the Preview StatsComponent

You can create a Preview StatsComponent using CreatePreviewStatsComponent().

This will create a copy of the target StatsComponent.

warning

Remember to destroy the Preview StatsComponent once you're done with it.

Get the Preview StatsComponent

Once you've created a Preview StatsComponent, you can access it with GetPreviewStatsComponent() and modify it like a normal StatsComponent.

Destroy the Preview StatsComponent

Once you're done with your modifications, you can use DestroyPreviewStatsComponent().

Validate Changes set to false will just destroy the Preview StatsComponent.
Setting it to true will set the target StatsComponent to the same state as the Preview before destroying it.

note

Right now, when you validate the changes, all Stats present in your StatsComponent are destroyed then created from the Preview StatsComponent.
If you have a widget that uses delegates to display your Stat values, they will become obsolete unless you take that into account with OnStatAdded / OnStatRemoved delegates.