using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class HeaderIconsProvider : MonoBehaviour { public List Icons; public GameObject defaultIcon; public GameObject GetIcon(string header) { //Проверки заполнения if (Icons == null) { Debug.LogError("Не заданы иконки"); return null; } if (defaultIcon == null) { Debug.LogError("Не задана иконка по умолчанию"); return null; } //поиск по id GameObject foundIcon = null; for (int i = 0; i < Icons.Count; i++) { if (Icons[i].Name == header) { foundIcon = Icons[i].IconPrefab; break; } } //возврат if (foundIcon == null) { Debug.LogError($"Иконка с id: {header} не найдено. Возврат дефолтного значения"); return defaultIcon; } return foundIcon; } [Serializable] public class HeaderIcon { public string Name; public GameObject IconPrefab; } }