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

namespace NBF.Setting
{
    /// <summary>
    /// 全局各向异性纹理过滤模式
    /// </summary>
    [Sort(7)]
    public class AnisotropicModeSetting : MultiOption<AnisotropicFiltering>
    {
        public override string Name => "AnisotropicMode";
        public override string Group => SettingsDef.Group.Graphic;
        public override string Tab => SettingsDef.Tab.Graphic;

        protected override int DefaultValue => (int)AnisotropicFiltering.Enable;

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

        protected override void OnApply()
        {
            // 获取当前URP Asset
            UniversalRenderPipelineAsset URPAsset =
                QualitySettings.GetRenderPipelineAssetAt(QualitySettings.GetQualityLevel()) as
                    UniversalRenderPipelineAsset;
            if (URPAsset)
            {
                //全局各向异性纹理过滤模式
                QualitySettings.anisotropicFiltering = GetSelectedOption();
            }
        }
    }
}