using UnityEditor;
using UnityEngine;

namespace SwhiteGames.Editor {
    [CustomEditor(typeof(GameConfig))]
    public class GameConfigEditor : UnityEditor.Editor {
        public override void OnInspectorGUI() {
            DrawDefaultInspector(); // 可选：绘制默认 Inspector

            var gameConfig = (GameConfig) target;

            // 包名
            gameConfig.packageName = EditorGUILayout.TextField("包名", gameConfig.packageName);

            // isRelease 选项
            EditorGUI.BeginDisabledGroup(true);

            EditorGUILayout.Toggle(new GUIContent("isRelease", "是否为发布版本, 由玩家设置中脚本定义符 GAME_RELEASE 决定"),
                gameConfig.isRelease);
            EditorGUI.EndDisabledGroup();

            // 启用日志（随 isRelease 联动）
            EditorGUI.BeginDisabledGroup(gameConfig.isRelease);
            gameConfig.enabledLog =
                EditorGUILayout.Toggle(new GUIContent("启用日志", "发布版本默认不可启动日志"), gameConfig.enabledLog);
            EditorGUI.EndDisabledGroup();

#if UNITY_ANDROID
            // 硬件加速
            gameConfig.hardwareAcceleration = EditorGUILayout.Toggle("硬件加速", gameConfig.hardwareAcceleration);
#endif

            // 标记对象已修改，确保更改能保存
            if (GUI.changed) {
                EditorUtility.SetDirty(gameConfig);
            }
        }
    }
}
