// MIT License - Copyright (c) 2025 wallstop
// Full license text: https://github.com/wallstop/unity-helpers/blob/main/LICENSE
// ReSharper disable once CheckNamespace
namespace WallstopStudios.UnityHelpers.Core.Extension
{
using UnityEngine;
using UnityEngine.UI;
public static partial class UnityExtensions
{
///
/// Sets all color states of a UI Slider to the same color.
///
public static void SetColors(this Slider slider, Color color)
{
ColorBlock block = slider.colors;
block.normalColor = color;
block.highlightedColor = color;
block.pressedColor = color;
block.selectedColor = color;
block.disabledColor = color;
slider.colors = block;
}
///
/// Sets the left offset of a RectTransform.
///
public static void SetLeft(this RectTransform rt, float left)
{
rt.offsetMin = new Vector2(left, rt.offsetMin.y);
}
///
/// Sets the right offset of a RectTransform.
///
public static void SetRight(this RectTransform rt, float right)
{
rt.offsetMax = new Vector2(-right, rt.offsetMax.y);
}
///
/// Sets the top offset of a RectTransform.
///
public static void SetTop(this RectTransform rt, float top)
{
rt.offsetMax = new Vector2(rt.offsetMax.x, -top);
}
///
/// Sets the bottom offset of a RectTransform.
///
public static void SetBottom(this RectTransform rt, float bottom)
{
rt.offsetMin = new Vector2(rt.offsetMin.x, bottom);
}
}
}