using System;
using System.Collections.Generic;
using System.Linq;
using RosettaUI.Swatch;
using UnityEngine;
namespace RosettaUI.Builder
{
///
/// AnimationCurveSwatchのセーブロード
/// データ自体がなければデフォルト値をセーブする
///
public class AnimationCurveSwatchPersistentService : SwatchPersistentService
{
public AnimationCurveSwatchPersistentService(string keyPrefix) : base(keyPrefix)
{
}
public override IEnumerable> LoadSwatches()
{
if (!HasSwatches)
{
AddFactoryPreset();
}
return base.LoadSwatches();
}
public void AddFactoryPreset()
{
var swatches = base.LoadSwatches() ?? Array.Empty>();
SaveSwatches(swatches.Concat(AnimationCurveHelper.FactoryPresets.Select(curve =>
new NameAndValue { value = curve })));
}
}
}