45 lines
1.2 KiB
C#
45 lines
1.2 KiB
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;
|
|
public string overlayId; // Èìÿ overlay äëÿ ShowOverlay/HideOverlay
|
|
}
|
|
|
|
[SerializeField] private List<PanelRange> ranges = new List<PanelRange>();
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance == null) Instance = this;
|
|
else { Destroy(gameObject); return; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Âîçâðàùàåò ïàíåëü è overlayId ïî id íàñòðîéêè.
|
|
/// </summary>
|
|
public bool GetPanelInfo(int id, out SettingsPanelBase panel, out string overlayId)
|
|
{
|
|
foreach (var range in ranges)
|
|
{
|
|
if (id >= range.idMin && id <= range.idMax)
|
|
{
|
|
panel = range.panel;
|
|
overlayId = range.overlayId;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
Debug.LogWarning($"PanelRouter: id {id} íå íàéäåí");
|
|
panel = null;
|
|
overlayId = null;
|
|
return false;
|
|
}
|
|
} |