using UnityEngine; using System; using System.Collections.Generic; using System.Linq; using Octopus.Simulator; public class DataManager : UnitySingleton { public bool isPlaying = false; List models = new List(); public event Action> 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(); model.onModelClicked += FindAnyObjectByType(FindObjectsInactive.Include).SetConnectedDataItem; 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 GetModels() { return models; } public SimulationModel GetModel(string nodeID) { if (nodeID == null) return null; SimulationModel model = models.Find(x => x.nodeID.Equals(nodeID)); return model; } }