protected void Awake() { microgrid = FindObjectOfType <Microgrid>(); submitButton.onClick.AddListener(Submit); canBuyToggle.onValueChanged.AddListener(b => canBuy = b); canSellToggle.onValueChanged.AddListener(b => canSell = b); canBuyToggle.isOn = canBuy; canSellToggle.isOn = canSell; loadMultIF.richText = false; loadMultIF.contentType = TMP_InputField.ContentType.DecimalNumber; loadMultIF.onValueChanged.AddListener(s => SetLoadMultiplier(s)); renewableMultIF.richText = false; renewableMultIF.contentType = TMP_InputField.ContentType.DecimalNumber; renewableMultIF.onValueChanged.AddListener(s => SetRenewableMultiplier(s)); batteryRatedPowerIF.richText = false; batteryRatedPowerIF.contentType = TMP_InputField.ContentType.DecimalNumber; batteryRatedPowerIF.onValueChanged.AddListener(s => batteryRatedPower = float.Parse(s)); batteryRatedEnergyIF.richText = false; batteryRatedEnergyIF.contentType = TMP_InputField.ContentType.DecimalNumber; batteryRatedEnergyIF.onValueChanged.AddListener(s => batteryRatedEnergy = float.Parse(s)); loadAverageIF.interactable = false; loadAverageIF.contentType = TMP_InputField.ContentType.DecimalNumber; loadPeakIF.interactable = false; loadPeakIF.contentType = TMP_InputField.ContentType.DecimalNumber; loadMinIF.interactable = false; loadMinIF.contentType = TMP_InputField.ContentType.DecimalNumber; renewableAverageIF.interactable = false; renewableAverageIF.contentType = TMP_InputField.ContentType.DecimalNumber; renewablePeakIF.interactable = false; renewablePeakIF.contentType = TMP_InputField.ContentType.DecimalNumber; renewableMinIF.interactable = false; renewableMinIF.contentType = TMP_InputField.ContentType.DecimalNumber; foreach (var gen in ThermalGeneratorPresets.EnumeratePresets()) { AddGeneratorEntry(gen.Key, gen.Value); } foreach (var gen in ThermalGeneratorPresets.presetGroup[0]) { var i = generatorEntries.FindIndex(x => x.generatorName == gen.Item1); if (i > 0) { generatorEntries[i].SetQuantity(gen.Item2); } } }
private void PopulateGeneratorList() { foreach (var gen in ThermalGeneratorPresets.EnumeratePresets()) { var toggle = Instantiate(generatorTogglePrototype); toggle.transform.SetParent(generatorContainer); toggle.GetComponentInChildren <TMP_Text>().text = gen.Key; toggle.onValueChanged.AddListener((bool isOn) => OnGeneratorToggle(toggle, isOn)); generatorToggles.Add(toggle, Tuple.Create(gen.Key, gen.Value)); } }