Skip to content

Commit

Permalink
Fix nested color picker submit not updating correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
XAce1337manX committed Jul 9, 2024
1 parent f14fa8a commit c7c1214
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class NestedColorPickerComponent : CMUIComponentWithLabel<Color>, INaviga
// Cached dialog box
private static DialogBox nestedDialogBox;
private static ColorPickerComponent nestedColorPicker;
private static ButtonComponent submitButton;

[SerializeField] private Button editButton;
[SerializeField] private TextMeshProUGUI hexColorText;
Expand Down Expand Up @@ -68,12 +69,20 @@ private void OnEditButtonClick()

var cancel = nestedDialogBox.AddFooterButton(null, "PersistentUI", "cancel");

var submit = nestedDialogBox.AddFooterButton(() => Value = nestedColorPicker.Value, "PersistentUI", "ok");
submitButton = nestedDialogBox.AddFooterButton(() => Value = nestedColorPicker.Value, "PersistentUI", "ok");

nestedDialogBox.OnQuickSubmit(() => OnValueUpdated(nestedColorPicker.Value));
}
else
{
// We need to refresh the submit and quick submit callbacks here otherwise the cached instance will be
// editing the previewImage and hexColorText from the first dialog this was created from
submitButton.OnClick(() => {
Value = nestedColorPicker.Value;
nestedDialogBox.Close();
});
nestedDialogBox.OnQuickSubmit(() => OnValueUpdated(nestedColorPicker.Value));

nestedColorPicker.Value = Value;
}

Expand Down

0 comments on commit c7c1214

Please sign in to comment.