FloatData - CodingDino/Dino-Unity-Toolkit GitHub Wiki

The FloatData component stores a single floating point value, aka float. A float is a number value that can have decimal places and be negative. If you don't want to allow decimal places, use an IntData instead for whole numbers (integers aka ints) only.

A FloatData is most commonly used with the TimerAction component to store time values. You might also use it to store distance, speed, or other values which need decimal places.

This is a Data component, and includes both Action functions and Activator triggers. Actions, Activators, and Data make up the core system for the Dino Unity Toolkit.

Image: A FloatData component set up to work with a TimerAction as a countdown from 20 seconds. When it reaches 0, it will spawn a copy of the player (using a SpawnObjectAction and reset its own value back to 20, restarting the countdown. It is also set up to send its value to a UITextAction each time it changes.

Image: The FloatData from above in action.

Properties

Settings

These settings set limits and conditions for the FloatData.

Parameter: Description:
Starting Value The starting value for the FloatData.
Has Min Value Does the FloatData have a minimum value?
Min Value The minimum value for the FloatData - only used if Has Min Value is true.
Has Max Value Does the FloatData have a maximum value?
Max Value The maximum value for the FloatData - only used if Has Max Value is true.
Save ID What ID should this value be saved under? This must be UNIQUE - any shared IDs will override eachother when saving.

If Has Min Value is set to true, the current value of the FloatData will not be allowed to fall below the minimum value, and if it reaches or exceeds that value, the On Value Min actions will be activated.

The same is true for Has Max Value - if the FloatData's current value meets or exceeds the Max Value, it will be clamped to the Max Value and the On Value Max actions will be activated.

Activation List

These are the lists of actions that will be activated when the above conditions are met

Parameter: Description:
On Value Change () Activates any time the current value is changed (different from previous value)
On Value Max () Activates once when the current value changes to the maximum value
On Value Min () Activates once when the current value changes to the minimum value

Actions

This component has several Action functions that can be triggered by Activators.

ActionResetValue

This action sets the reset value to the starting value.

ActionSetValue

This action sets the current value to the provided value. It will check if this new value is different from the old one and activate the On Value Change () actions if so. It will also check against minimum and maximum values, clamp the current value if necessary, and activate On Value Max () or On Value Min () actions as appropriate.

Parameter: Description:
New Value The new value that the data will be set to

ActionAddValue

This action adds the supplied value to the current data value, or subtracts if negative. It will check if the resulting value is different from the old one and activate the On Value Change () actions if so. It will also check against minimum and maximum values, clamp the current value if necessary, and activate On Value Max () or On Value Min () actions as appropriate.

Parameter: Description:
To Add This value will be added to the current data value. Use a negative number to subtract.

ActionSaveValue

This action saves the current data value to the player preferences, which can then preserve between scenes or be saved to disk. The Save ID must be set in the component's settings for this action to succeed - otherwise, an error will be printed.

ActionLoadValue

This action loads a value saved previously in the player preferences and stores it in the current data value for this component. The Save ID must be set in the component's settings for this action to succeed - otherwise, an error will be printed.

ActionClearSavedValue

This action clears the value saved previously in the player preferences. The Save ID must be set in the component's settings for this action to succeed - otherwise, an error will be printed.