using System;
using UnityEngine;
using UnityEngine.Rendering.Universal;

namespace NBF.Setting
{
    public enum MsaaSampleEnum
    {
        Off = 1,
        x2 = 2,
        x4 = 4,
        x8 = 8
    }

    [Sort(6)]
    public class MsaaSampleSetting : MultiOption<MsaaSampleEnum>
    {
        public override string Name => "MsaaSample";
        public override string Group => SettingsDef.Group.Graphic;
        public override string Tab => SettingsDef.Tab.Graphic;
        protected override int DefaultValue => (int)MsaaSampleEnum.Off;

        protected override void OnInitialize()
        {
            var enumValues = Enum.GetValues(typeof(MsaaSampleEnum));
            foreach (var value in enumValues)
            {
                AddOption(value.ToString(), (MsaaSampleEnum)value);
            }
        }

        protected override void OnApply()
        {
            // 获取当前URP Asset
            UniversalRenderPipelineAsset URPAsset =
                QualitySettings.GetRenderPipelineAssetAt(QualitySettings.GetQualityLevel()) as
                    UniversalRenderPipelineAsset;
            if (URPAsset)
            {
                //抗锯齿等级
                URPAsset.msaaSampleCount = (int)GetSelectedOption();
                URPAsset.supportsHDR = true;
            }
        }
    }
}