// Filename: EC_UIUtility.cs
// Creator: Extracted from EC_InventoryUI.cs
// Date: 2024
// Purpose: Reusable UI helper functions for panel positioning, text handling, and layout management
using UnityEngine;
using UnityEngine.UI;
namespace BrewMonster.Scripts.UI
{
///
/// General-purpose UI utility class providing reusable functions for:
/// - Smart panel positioning near buttons with edge detection
/// - Dual text component support (Legacy Text + TextMeshPro)
/// - Layout refresh helpers
///
public static class EC_UIUtility
{
///
/// Position a panel near a button with smart edge detection to keep panel on screen.
/// Automatically chooses left or right placement based on available space.
///
/// The panel RectTransform to position
/// The button RectTransform to position near
/// Offset from button (x: horizontal spacing, y: vertical offset)
public static void PositionPanelNearButton(RectTransform panelRect, RectTransform buttonRect, Vector2 offset)
{
if (panelRect == null || buttonRect == null)
{
Debug.LogWarning("[EC_UIUtility] PositionPanelNearButton: panelRect or buttonRect is null");
return;
}
var canvas = panelRect.GetComponentInParent