public CheckboxOption(GameObject parentGO, ModSettingBool modSettingBool) : base(parentGO, modSettingBool, "CheckboxOption") { checkbox = instantiatedGameObject.transform.Find("Checkbox1").GetComponent <Toggle>(); checkboxText = instantiatedGameObject.transform.Find("Checkbox1/Label").GetComponent <Text>(); checkbox.AddOnValueChanged(value => modSettingBool.SetValue(value)); }
internal CheckboxOption(GameObject parentGO, ModSettingBool modSettingBool) : base(parentGO, modSettingBool, "CheckboxOption") { this.modSettingBool = modSettingBool; Checkbox = instantiatedGameObject.transform.Find("Checkbox1").GetComponent <Toggle>(); CheckboxText = instantiatedGameObject.transform.Find("Checkbox1/Label").GetComponent <Text>(); Checkbox.Set(modSettingBool); Checkbox.AddOnValueChanged(value => modSettingBool.SetValue(value)); modSettingBool.OnInitialized.InvokeAll(this); }
internal ButtonOption(GameObject parentGO, ModSettingBool modSetting) : base(parentGO, modSetting, "ButtonOption") { Button = instantiatedGameObject.transform.Find("Button").GetComponent <Button>(); ButtonText = instantiatedGameObject.transform.Find("Button/Text").GetComponent <Text>(); //button.onClick.AddListener(new Action(() => { buttonPressed(); })); //how you'd normally setup button events //button.AddOnClick(buttonPressed); //you can also add OnClick events using this BTD6 Mod Helper extension modSetting.OnInitialized.InvokeAll(this); Button.AddOnClick(() => modSetting.SetValue(!modSetting.value)); }