using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;

public class DeformationToggleManager : MonoBehaviour {

    [SerializeField]
    private ToggleGroup toggleGroup;

    [SerializeField]
    private GameObject _togglePrefab;

    [SerializeField]
    private DeformationManager _deformationManager;

    private void Start()
    {
        SetupToggles();
    }

    public void SetupToggles()
    {

        _deformationManager.Deformations.ToList().ForEach(item =>
        {
            GameObject newObject = Instantiate(_togglePrefab, transform);
            DeformationToggle newToggleScript = newObject.GetComponent<DeformationToggle>();
            if (newToggleScript != null)
            {
                newToggleScript.Setup(_deformationManager, item, toggleGroup);
            }
        
        });
    }

    
}
