Yes, I meant a whole example zscript that I can test. But I think the most likely explanation is that you are simply seeing the switch reset to its default when the plugin is reloaded. In the code you have given the switch state is off when the plugin loads. It’s a quirk of ISwitches that you have to press them twice to get them to respond if the plugin isn’t already loaded. The first press loads the plugin and the second press actually presses the switch. This isn’t new to 4R8 - it’s been in ZBrush for as long as I remember. (There are ways to avoid this behaviour but I shan’t go into that here.)
For your switch turning off when you press a button, this again is when the plugin is reloaded. You can test this by using a different plugin, such as the hotkeys [ or ] to change the Draw Size, and then pressing one of your plugin’s buttons. You’ll see the switch go off because that’s its default state in your code. The easiest way to avoid this is to use a memory block to for the switch state. The code below shows how to do it. It also has a switch with no memory block so you can compare the behaviour.
[If,[MemGetSize,MySwitchMem],
[MVarDef,MySwitchMem,1,0][MVarSet,MySwitchMem,0,0]
]
[ISubPalette,“Zplugin:Marcus Tools”]
[ISwitch,“Zplugin:Marcus Tools:My Switch”
,[MVarGet,MySwitchMem,0],“Popup info Text”
,[MVarSet,MySwitchMem,0,1]
,[MVarSet,MySwitchMem,0,0]
,0.5]
[ISwitch,“Zplugin:Marcus Tools:My Switch2”
,0,“Popup info Text”
,
,
,0.5]
[IButton,“Zplugin:Marcus Tools:My Button”,“Popup info Text”
,
,
,0.5]
[IEnable,“Zplugin:Marcus Tools:My Switch”]
[IEnable,“Zplugin:Marcus Tools:My Switch2”]