1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 04:13:32 +08:00

UXAssist 1.2.4

This commit is contained in:
2024-09-24 00:33:41 +08:00
parent daaf7b4901
commit 237830fc91
13 changed files with 149 additions and 73 deletions

View File

@@ -13,8 +13,13 @@ public class MyCheckBox : MonoBehaviour
public RectTransform rectTrans;
public Text labelText;
public event Action OnChecked;
protected event Action OnFree;
private bool _checked;
private ConfigEntry<bool> _configAssigned;
protected void OnDestroy()
{
OnFree?.Invoke();
}
public bool Checked
{
@@ -29,9 +34,10 @@ public class MyCheckBox : MonoBehaviour
public static MyCheckBox CreateCheckBox(float x, float y, RectTransform parent, ConfigEntry<bool> config, string label = "", int fontSize = 15)
{
var cb = CreateCheckBox(x, y, parent, config.Value, label, fontSize);
cb._configAssigned = config;
cb.OnChecked += () => config.Value = !config.Value;
config.SettingChanged += (_, _) => cb.Checked = config.Value;
EventHandler func = (_, _) => cb.Checked = config.Value;
config.SettingChanged += func;
cb.OnFree += () => config.SettingChanged -= func;
return cb;
}