Danro/Assets/Scripts/Editor/SettingsDatabaseEditor.cs
Danil Iarosh 4d05d1adbb
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
FEAT: Added new settings system
- Добавил новую систему настроек, возможности:
    - Динамически создает список настроек
    - Сохраняет настройки в JSON-файл
    - Возможность группировать настройки
    - Широкие возможности по кастомизации
    - Применение настроек в реальном времени (частично)
- Добавил префабы для новых элементов настроек
- Изменил поведение игры исходя из нового формата настроек
2026-02-04 14:32:15 +03:00

46 lines
1.3 KiB
C#

#if UNITY_EDITOR
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using RR.Common.Settings;
namespace RR.Common.InspectorOverrides
{
[CustomEditor(typeof(SettingsDatabase))]
public class SettingsDatabaseEditor : Editor
{
private ReorderableList _list;
private void OnEnable()
{
var entriesProp = serializedObject.FindProperty("entries");
_list = new ReorderableList(serializedObject, entriesProp, true, true, true, true);
_list.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "Settings Entries");
_list.elementHeightCallback = index =>
{
var element = entriesProp.GetArrayElementAtIndex(index);
return EditorGUI.GetPropertyHeight(element, true) + 8f;
};
_list.drawElementCallback = (rect, index, isActive, isFocused) =>
{
var element = entriesProp.GetArrayElementAtIndex(index);
rect.y += 4f;
rect.height -= 4f;
EditorGUI.PropertyField(rect, element, GUIContent.none, true);
};
}
public override void OnInspectorGUI()
{
serializedObject.Update();
_list.DoLayoutList();
serializedObject.ApplyModifiedProperties();
}
}
}
#endif