using Cryville.EEW.Core;
using UnityEngine;

namespace Cryville.EEW.Unity.UI {
	class EventUnitListView : MonoBehaviour {
		[SerializeField]
		EventUnitView m_prefabEventUnitView;

		public void Set(ReportGroup group) {
			foreach (Transform child in transform) {
				Destroy(child.gameObject);
			}
			foreach (var unit in group) {
				Add(unit);
			}
		}
		void Add(ReportUnit unit) {
			var child = Instantiate(m_prefabEventUnitView);
			child.Set(unit);
			child.transform.SetParent(transform, false);
			child.transform.SetSiblingIndex(0);
		}
	}
}
