ProjectDDD/Assets/_DDD/_Scripts/GameUi/Utils/Binding/BindingHelper.cs

39 lines
1.5 KiB
C#
Raw Normal View History

2025-08-21 07:25:27 +00:00
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace DDD
{
public static class BindingHelper
{
public static void BindText(BindingContext context, TextMeshProUGUI text, string propertyPath, IValueConverter converter = null)
{
var target = new TextBindingTarget(text, propertyPath);
context?.Bind(propertyPath, target, converter);
}
public static void BindImage(BindingContext context, Image image, string propertyPath, IValueConverter converter = null)
{
var target = new ImageBindingTarget(image, propertyPath);
context?.Bind(propertyPath, target, converter);
}
public static void BindImageFilled(BindingContext context, Image image, string propertyPath, IValueConverter converter = null)
{
var target = new ImageFilledBindingTarget(image, propertyPath);
context?.Bind(propertyPath, target, converter);
}
public static void BindActive(BindingContext context, GameObject gameObject, string propertyPath, IValueConverter converter = null)
{
var target = new ActiveBindingTarget(gameObject, propertyPath);
context?.Bind(propertyPath, target, converter);
}
public static void BindSlider(BindingContext context, Slider slider, string propertyPath, IValueConverter converter = null)
{
var target = new SliderBindingTarget(slider, propertyPath);
context?.Bind(propertyPath, target, converter);
}
}
}