I recently started using delegates and I find myself in a bit of a situation.
I have a checkbox and Basically I want to uncheck all other checkboxes when one is checked (Only one can be checked at a time)
My thought was to use OnCheckStateChanged.AddDynamic(), however, it seems that I can’t bind any extra parameters like a reference to the checkbox itself?
In my function I planned to loop through the checkboxes and if it’s not the one just clicked (passed via the delegate, bound) then uncheck it.
It seems like you can’t bind any more variables and also can’t use lambda to capture the variable, so I’m very confused as to how I am even supposed to do this?
You can use a two param delegate and pass the reference and keep track of which one is selected and uncheck the old one. You will need to add your own delegate.
Another solution is to have the array of all checkboxes saved and bind their event and figure out which one should be the current selected, here’s a rough example:
In header I have these variables
You will then need to fill that array with your checkboxes and then bind their event
how would i use a two param delegate for the oncheckstatuschanged event?
your explanation was my idea, however, as i unferstand it when you vheck a second box, and one is already checked, you will have two checked boxes and one needs unchecking, so youd need to know which one is which for what you need a reference. Are you sayinf if i keep the ref at the start then that solves it?
This seems a bit convoluted, could you explain more of the other way?
As i understand it the delegate that gets triggered when check status changes is the one that alreasy is built in, can i fire my own delegate on that event?