Bindings
Now, we will change the localization key to 'label_current_data' and set up the binding.
This means that the localization script will automatically retrieve the value from a specific field in the MonoBehaviour script and insert it into the localization text, updating it in real time.
This allows changes in the data to be immediately reflected in the UI without any additional actions.

Enable the "Binding Enabled" checkbox to make the binding settings visible. Then, serialize the GameObject that contains the script from which you want to retrieve the value. Click on the combobox and select the desired value. This process is similar to selecting the OnClick method for a UI.Button component.

The "Argument Index" field contains the index for string.Format(). In the case of the localization "Current value: {0}", we set the value to 0 because it corresponds to the placeholder with a zero index.
You can bind values from different GameObjects and scripts into a single localization, and you can bind the same field to different placeholders, but you cannot bind two different fields to the same placeholder.
You can bind private, public, static, and instance properties and fields of the following types: string, int, float, double, long, short, byte, decimal.
When you run your project in Playmode, you'll see that the counter in the script InfinityIncrementInt.cs is increasing, and the text component displays its current value without any additional code.

If you want to optimize the binding, you can adjust the value update frequency, which is controlled by the "Binding Rate Ms" field.
If two different numbers are set, Random.Range will be used for the delay, and if two identical numbers are set, a fixed delay will be used.
The value is set in milliseconds.

Last updated