- Created AdvancedLoggingExample class demonstrating composite and file loggers - Implemented multi-file logging setup with separate error and full logs - Added game event and performance logging methods - Included key input handling for log operations (flush, clear) - Setup proper resource disposal on application quit
242 lines
8.7 KiB
C#
242 lines
8.7 KiB
C#
// using System.Collections;
|
||
// using System.Collections.Generic;
|
||
// using System.Reflection;
|
||
// using TMPro;
|
||
// using UnityEngine;
|
||
//
|
||
// public class SettingsScreen : MonoBehaviour
|
||
// {
|
||
// [Header("Панель с опциями")]
|
||
// [SerializeField] RectTransform OptionsRect;
|
||
//
|
||
// [Header("Панель с вариантами опций")]
|
||
// [SerializeField] RectTransform ValuesRect;
|
||
//
|
||
// [Header("Указатель опций")]
|
||
// [SerializeField] RectTransform PointerRect;
|
||
//
|
||
// [Header("Префаб текста настройки")]
|
||
// [SerializeField] GameObject SettingPrefab;
|
||
//
|
||
// [Header("Префаб текста опции")]
|
||
// [SerializeField] GameObject OptionPrefab;
|
||
//
|
||
//
|
||
// List<GameObject> settingsLabels;
|
||
// List<GameObject> optionsLabels;
|
||
//
|
||
// substate currentState;
|
||
//
|
||
// List<SettingOption> gameSettings => SettingsManager.instance.gameSettings.settings;
|
||
// int settingsAmount => SettingsManager.instance.gameSettings.settings.Count;
|
||
// List<string> chosenSettingOptions => SettingsManager.instance.gameSettings.settings[currentSettingIndex].options;
|
||
// int chosenSettingOptionsAmount => chosenSettingOptions.Count;
|
||
//
|
||
//
|
||
// public int currentSettingIndex = 0;
|
||
// int currentOptionIndex = 0;
|
||
//
|
||
//
|
||
// float startx = 50;
|
||
// float starty = -50;
|
||
//
|
||
// //float offsetx = 100;
|
||
// float offsetx = 0;
|
||
// float offsety = 70;
|
||
//
|
||
// Coroutine chooseOption;
|
||
//
|
||
// [SerializeField] float optionsPadding = 20;
|
||
//
|
||
// public void Open()
|
||
// {
|
||
// optionsLabels = new();
|
||
// settingsLabels = new();
|
||
// PointerRect.gameObject.SetActive(true);
|
||
// currentState = substate.SettingChoosing;
|
||
// currentSettingIndex = 0;
|
||
// CreateSettingsLabels();
|
||
// }
|
||
//
|
||
// public void Close()
|
||
// {
|
||
// ClearOptionsPanel();
|
||
// ClearSettingsPanel();
|
||
// if (chooseOption != null) StopCoroutine(chooseOption);
|
||
// }
|
||
//
|
||
// public void Switch(int direction)
|
||
// {
|
||
// switch (currentState)
|
||
// {
|
||
// case substate.SettingChoosing:
|
||
// currentSettingIndex = (currentSettingIndex + settingsAmount + direction) % settingsAmount;
|
||
// PointerRect.anchoredPosition = new Vector2(startx + currentSettingIndex * offsetx, starty - currentSettingIndex * offsety);
|
||
// break;
|
||
// case substate.OptionChoosing:
|
||
// currentOptionIndex = (currentOptionIndex + chosenSettingOptionsAmount + direction) % chosenSettingOptionsAmount;//ТУТ НАДО КОЛИЧЕСТВО ОПЦИЙ НАСТРОЙКИ ПОЛУЧИТЬ
|
||
// break;
|
||
// }
|
||
// //SoundManager.instance.playSwitch();
|
||
// }
|
||
//
|
||
// //менять состояние, сохранять данные
|
||
// public void Accept()
|
||
// {
|
||
// if (currentState == substate.SettingChoosing)
|
||
// {
|
||
// createOptionsLabels(gameSettings[currentSettingIndex]);
|
||
// currentState = substate.OptionChoosing;
|
||
// PointerRect.gameObject.SetActive(false);
|
||
//
|
||
// StartCoroutine(DisplayChosenOption());
|
||
// }
|
||
//
|
||
// else if (currentState == substate.OptionChoosing)
|
||
// {
|
||
// SettingsManager.instance.ChangeSetting(settingName: gameSettings[currentSettingIndex].settingName,
|
||
// newIndex: currentOptionIndex);
|
||
//
|
||
// PointerRect.gameObject.SetActive(true);
|
||
// ClearOptionsPanel();
|
||
// //Обновляем для учета изменений
|
||
// ClearSettingsPanel();
|
||
// CreateSettingsLabels();
|
||
//
|
||
// if (chooseOption != null) StopCoroutine(chooseOption);
|
||
//
|
||
// currentState = substate.SettingChoosing;
|
||
// }
|
||
//
|
||
// //SoundManager.instance.playChoose();
|
||
//
|
||
// }
|
||
//
|
||
//
|
||
//
|
||
// //Шерстим все существующие настройки
|
||
// //Создаем для каждой настройки текстовое поле
|
||
// private void CreateSettingsLabels()
|
||
// {
|
||
// settingsLabels = new List<GameObject>();
|
||
// //currentSettingIndex = 0;
|
||
// for (int i = 0; i < SettingsManager.instance.gameSettings.settings.Count; i++)
|
||
// {
|
||
// createLabelFromSettingOption(SettingsManager.instance.gameSettings.settings[i], i);
|
||
// //currentSettingIndex++;
|
||
// }
|
||
// //currentSettingIndex = 0;
|
||
// PointerRect.anchoredPosition = new Vector2(startx + currentSettingIndex * offsetx, starty - currentSettingIndex * offsety);
|
||
//
|
||
// //Процедура которая собственно создает лейблы
|
||
// void createLabelFromSettingOption(SettingOption option, int index)
|
||
// {
|
||
// GameObject label = Instantiate(SettingPrefab, OptionsRect);
|
||
// label.name = option.settingName + " Setting";
|
||
// settingsLabels.Add(label);
|
||
// RectTransform rt = label.GetComponent<RectTransform>();
|
||
// rt.anchoredPosition = new Vector2(startx + offsetx * index, starty - offsety * index);
|
||
//
|
||
// //Звгоняем название настройки
|
||
// TextMeshProUGUI text = rt.gameObject.GetComponent<TextMeshProUGUI>();
|
||
// text.text = option.settingName;
|
||
//
|
||
// //Текущая включенная опция
|
||
// GameObject label2 = Instantiate(OptionPrefab, rt);
|
||
// label2.name = option.settingName + " Value";
|
||
// RectTransform option_rt = label2.GetComponent<RectTransform>();
|
||
//
|
||
// option_rt.anchoredPosition = new Vector2(rt.sizeDelta.x, 0);
|
||
//
|
||
// text = option_rt.gameObject.GetComponent<TextMeshProUGUI>();
|
||
// text.text = option.ChosenOption;
|
||
// }
|
||
//
|
||
//
|
||
// }
|
||
//
|
||
// // Опции настроек
|
||
// void createOptionsLabels(SettingOption option)
|
||
// {
|
||
//
|
||
// currentOptionIndex = 0;
|
||
//
|
||
// float labelWidth = (ValuesRect.sizeDelta.x - optionsPadding * 2) / option.options.Count;
|
||
// float labelHeight = ValuesRect.sizeDelta.y - optionsPadding * 2;
|
||
// print(ValuesRect.sizeDelta);
|
||
//
|
||
// foreach (string optionName in option.options)
|
||
// {
|
||
// GameObject label = Instantiate(OptionPrefab, ValuesRect);
|
||
// optionsLabels.Add(label);
|
||
//
|
||
// RectTransform rt = label.GetComponent<RectTransform>();
|
||
// rt.pivot = new Vector2(0, 1f);
|
||
// rt.sizeDelta = new Vector2(labelWidth, labelHeight);
|
||
// rt.anchoredPosition = new Vector2(optionsPadding + labelWidth * currentOptionIndex, optionsPadding);
|
||
//
|
||
//
|
||
// TextMeshProUGUI text = label.GetComponent<TextMeshProUGUI>();
|
||
// text.text = optionName;
|
||
// text.alignment = TextAlignmentOptions.Center;
|
||
// text.color = Color.gray;
|
||
// currentOptionIndex++;
|
||
// }
|
||
// currentOptionIndex = option.chosenIndex;
|
||
// }
|
||
// void ClearSettingsPanel()
|
||
// {
|
||
// foreach (GameObject label in settingsLabels)
|
||
// {
|
||
// Object.Destroy(label);
|
||
// }
|
||
// settingsLabels.Clear();
|
||
// }
|
||
// void ClearOptionsPanel()
|
||
// {
|
||
// foreach (GameObject label in optionsLabels)
|
||
// {
|
||
// Object.Destroy(label);
|
||
// }
|
||
// optionsLabels?.Clear();
|
||
// }
|
||
//
|
||
// IEnumerator DisplayChosenOption()
|
||
// {
|
||
// Color normalColor = Color.gray;
|
||
// Color highlightedColor = Color.white;
|
||
//
|
||
// int normalSize = 26;
|
||
// int chosenSize = 40;
|
||
//
|
||
// List<TextMeshProUGUI> options = new List<TextMeshProUGUI>();
|
||
// foreach (GameObject label in optionsLabels)
|
||
// {
|
||
// options.Add(label.GetComponent<TextMeshProUGUI>());
|
||
// }
|
||
//
|
||
// while (true)
|
||
// {
|
||
// for (int i = 0; i < options.Count; i++)
|
||
// {
|
||
// if (i == currentOptionIndex)
|
||
// {
|
||
// options[i].color = Vector4.MoveTowards(options[i].color, highlightedColor, Time.deltaTime * 5);
|
||
// options[i].fontSize = Mathf.MoveTowards(options[i].fontSize, chosenSize, Time.deltaTime * 140);
|
||
// }
|
||
// else
|
||
// {
|
||
// options[i].color = Vector4.MoveTowards(options[i].color, normalColor, Time.deltaTime * 5);
|
||
// options[i].fontSize = Mathf.MoveTowards(options[i].fontSize, normalSize, Time.deltaTime * 140);
|
||
// }
|
||
// }
|
||
// yield return null;
|
||
// }
|
||
//
|
||
//
|
||
//
|
||
// }
|
||
//
|
||
// enum substate { SettingChoosing, OptionChoosing }
|
||
// }
|