2026-01-09 08:45:22 +03:00

40 lines
975 B
C#

using System.Collections.Generic;
using UnityEngine;
public class PanelRouter : MonoBehaviour
{
public static PanelRouter Instance { get; private set; }
[System.Serializable]
public class PanelRange
{
public int idMin;
public int idMax;
public SettingsPanelBase panel;
}
[SerializeField] private List<PanelRange> ranges = new List<PanelRange>();
private void Awake()
{
if (Instance == null) Instance = this;
else { Destroy(gameObject); return; }
}
/// <summary>
/// Âîçâðàùàåò ïàíåëü ïî id (áåç ðàñ÷¸òà âàðèàíòà).
/// </summary>
public SettingsPanelBase GetPanel(int id)
{
foreach (var range in ranges)
{
if (id >= range.idMin && id <= range.idMax)
{
Debug.Log($"id ïàíåëè {id} ");
return range.panel;
}
}
Debug.Log($"id ïàíåëè {id} íå íàéäåí");
return null;
}
}