Bootstrap Chameleon Logo

OnClose Callbacks

See It Through


Add "OnMapChangedCmd" to the Chameleon tool for executing Python commands when changing maps.


  • Clean references in Chameleon tool when unload map to avoid memory leaks
  • Clear references in Chameleon tools to prevent memory leaks
  • Sync the UI when changing map
  • Synchronize UI, such as refreshing the map list when switching maps, etc.

For example, add the "OnMapChangedCmd" field to a tool that may hold references to objects in the scene and add code to clear the references, such as:

    "OnMapChangedCmd": "chemeleon_objectDetailViewer.on_map_changed(%map_change_type)",
    def on_map_changed(self, map_change_type_str):
        # remove the reference, avoid memory leaking when load another map.
        if map_change_type_str == "TearDownWorld":
            pass # skip: LoadMap, SaveMap, NewMap


  • %world: Get the world of map operation
  • %world:Get the world (level) of map operation
  • %map_change_type: Get the operation type of changing map, "LoadMap", "SaveMap", "NewMap" or "TearDownWorld"
  • %map_change_type:Get the type of map operation, possible values are:
  • "LoadMap"
  • "SaveMap"
  • "NewMap"
  • "TearDownWorld"


The OnClosePyCmd field in Chameleon Tool is used to set the Python command executed when the user actively closes the Chameleon tool.

    "TabLabel": "KeypadCommunicator",
    "InitTabSize": [200, 80],
    "InitTabPosition": [1100, 20],
    "InitPyCmd": "import MidiCommander; import importlib; importlib.reload(MidiCommander); chameleon_midi = MidiCommander.MidiListener.MidiListener(%JsonPath);",
    "OnClosePyCmd": "chameleon_midi.on_ui_close()",