Component > Pixel Crushers > Dialogue System > Actor > Increment On Destroy
Increment On Destroy increments a Lua variable when the GameObject is destroyed or disabled.
Property | Function |
---|---|
Increment On | Specifies whether to increment when the GameObject is destroyed or disabled. |
Variable | The Lua variable to increment. This variable will be created if it's not already defined in the dialogue database. |
Increment | The amount to increment. Negative amounts decrement the value. |
Min | Guaranteed minimum value for the variable after incrementing. |
Max | Guaranteed maximum value for the variable after incrementing. |
Alert Message | An optional alert message to show. Can include Markup Tags. |
Alert Duration | Duration in seconds to show the alert. If zero, use the default duration. |
Condition | Conditions that must be true to increment the variable. |
OnIncrement() | UnityEvent that runs when incrementing the variable. |
This component is useful for kill quests or collection quests, as you can increment a counter every time the player kills or collects a specific GameObject.
Note that loading a new level will disable and destroy GameObjects in the current level. If you don't want to increment the variable in this situation, call SaveSystem.BeforeSceneChange
(if you've set up the save system) or PersistentDataManager.LevelWillBeUnloaded()
(if you haven't set up the save system) before loading the new level. The Dialogue System's save subsystem automatically calls this method, so if you're using it to change levels you don't need to do anything else.