32 lines
901 B
C#
32 lines
901 B
C#
using UnityEngine;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
public class DataManager : UnitySingleton<DataManager>
|
|
{
|
|
List<SimulationModel> models = new List<SimulationModel>();
|
|
|
|
public event Action<List<SimulationModel>> onModelsUpdated;
|
|
public void AddModel(SimulationModel model)
|
|
{
|
|
if (models.Any(x => x == model))
|
|
return;
|
|
int objCount = models.FindAll(x => x.modelName.Contains(model.modelName)).Count;
|
|
model.modelName = model.modelName + "_" + objCount.ToString();
|
|
models.Add(model);
|
|
onModelsUpdated?.Invoke(models);
|
|
}
|
|
public void RemoveModel(SimulationModel model)
|
|
{
|
|
if (models.Any(x => x == model))
|
|
return;
|
|
models.Remove(model);
|
|
onModelsUpdated?.Invoke(models);
|
|
}
|
|
|
|
public List<SimulationModel> GetModels()
|
|
{
|
|
return models;
|
|
}
|
|
}
|