using UnityEngine;
using System.Collections.Generic;

public class MorphPanel : MonoBehaviour
{
    [SerializeField] private MorphPanelCategory _morphPanelCategoryPfb;
    [SerializeField] private Transform _categoryPanels;
    public Dictionary<string, MorphPanelCategory> Categories = new Dictionary<string, MorphPanelCategory>();

    public static MorphPanel Create(List<string> categories)
    {
        var panel = Instantiate(SharedResources.Instance.MorphPanel, ModelViewerInterface.GetInstance().DynamicPanels.transform);
        panel.Init(categories);
        return panel;
    }

    public void Init(List<string> categories)
    {
        Categories.Clear();
        foreach (var category in categories)
        {
            var categoryPanel = Instantiate(_morphPanelCategoryPfb, _categoryPanels);
            categoryPanel.Label.text = category;
            Categories[category] = categoryPanel;
        }
    }

    public void CreateMorph(string category, ObjectContainer container, SkinnedMeshRenderer meshRenderer, int index, string displayName)
    {
        SliderPanel.CreateMorph(container, meshRenderer, index, displayName, this.Categories[category].Content);
    }
}
