Having an issue with unregistering a redraw viewport callback that was created in a scripted modifier.
It seems to create an instance of the callback for every object that has a the modifier which I’m guessing is the correct way it is supposed to function. I can also unregister the callback from the modifier.
My problem is unregistering it without the modifier, like when a new scene is loaded and the callback remains but the object that was used to create it is no longer there.
My second problem is even if I could access it, what would be the best way to remove it when loading a new scene? Registering a filepreopen callback?
Below is the code I am using to test.
plugin modifier TestAttributes
name:"Test Attributes"
classID:#(685321,452287)
extends:EmptyModifier
replaceUI:true
(
parameters main rollout:params
(
showPosPoint_btn type:#boolean animatable:false ui:showPosPoint_btn default:false
)
rollout params "Test Properties"
(
checkbutton showPosPoint_btn " Display Position Points " checked:false
global GW_displayObjectNames
fn GW_displayObjectNames =
(
gw.setTransform (matrix3 1)
for o in objects where not o.isHiddenInVpt do
gw.text o.pos (o as string) color:yellow
gw.enlargeUpdateRect #whole
)
on showPosPoint_btn changed state do
(
if state == true then
(
registerRedrawViewsCallback GW_displayObjectNames
)
else
(
unregisterRedrawViewsCallback GW_displayObjectNames
)
)
)
)