pKallv
January 21, 2018, 9:33am
1
I have a function:
public void Tgl_MustXXX (bool _xxx) {
This is connected to a UI Toggle. If i disable the toggle object it does not execute but if the toggle is enabled, not touched, in the UI when starting the app is actually been executed when starting up.
I have no code that reference this function at all, only the UI Toggle object.
Anyone with some idea’s what is happening?
mgear
January 21, 2018, 9:41am
2
need to check manually if its actually on or off,
Why not just check the toggle.isOn parameter to figure out if this one just turned on or off? There's also a boolean variable received by the onValueChange handler, which tells it whether it was switched on or off...
Note it's called "onValueChange" and not "onToggleOn", so it make sense it will be called both when turning on and when turning off.
toggle.onValueChanged.AddListener((bool on) => {
if (on) {
// Open the panel
}
…
1 Like
pKallv
January 25, 2018, 9:02pm
3
Thanks, i do that already.
So, are you asking why the changed callback is called?
pKallv
January 28, 2018, 5:30pm
5
I am asking why the function is called at start without me referencing it.
If I understand your question correctly, I think it’s being called because the toggle changes and every time it changes, that method is called.