void PollLoopWidgets() { for (int i = loopPanelWidgets.Count - 1; i >= 0; i--) { if (!simulator.HasLoop(loopPanelWidgets[i].trackedLoopID)) { Destroy(loopPanelWidgets[i].gameObject); loopPanelWidgets.RemoveAt(i); } } foreach (HeatLoop loop in simulator.HeatLoops) { bool generateWidget = true; for (int i = loopPanelWidgets.Count - 1; i >= 0; i--) { if (loopPanelWidgets[i].trackedLoopID == loop.ID) { generateWidget = false; } } if (generateWidget) { Utils.Log("[UI]: Generatoing a new loop widget", LogType.UI); GameObject newObj = (GameObject)Instantiate(SystemHeatUILoader.ToolbarPanelLoopPrefab, Vector3.zero, Quaternion.identity); newObj.transform.SetParent(loopPanelScrollRoot.transform); //newWidget.transform.localPosition = Vector3.zero; ToolbarPanelLoopWidget newWidget = newObj.AddComponent <ToolbarPanelLoopWidget>(); newWidget.AssignSimulator(simulator); newWidget.SetLoop(loop.ID); newWidget.SetVisible(true); loopPanelWidgets.Add(newWidget); } } }
void PollLoopWidgets() { for (int i = loopPanelWidgets.Count - 1; i >= 0; i--) { if (!simulator.HeatLoops.ContainsKey(loopPanelWidgets[i].trackedLoopID)) { Destroy(loopPanelWidgets[i].gameObject); loopPanelWidgets.RemoveAt(i); } } foreach (KeyValuePair <int, HeatLoop> keyValuePair in simulator.HeatLoops) { bool generateWidget = true; for (int i = loopPanelWidgets.Count - 1; i >= 0; i--) { if (loopPanelWidgets[i].trackedLoopID == keyValuePair.Key) { generateWidget = false; } } if (generateWidget) { GameObject newObj = (GameObject)Instantiate(SystemHeatUILoader.ToolbarPanelLoopPrefab, Vector3.zero, Quaternion.identity); newObj.transform.SetParent(loopPanelScrollRoot.transform); //newWidget.transform.localPosition = Vector3.zero; ToolbarPanelLoopWidget newWidget = newObj.AddComponent <ToolbarPanelLoopWidget>(); newWidget.AssignSimulator(simulator); newWidget.SetLoop(keyValuePair.Value.ID); newWidget.SetVisible(true); loopPanelWidgets.Add(newWidget); } } }