Asset hooks

Users can define new hooks that get called whenever the following assets are registered: Animation Clip, Agent Type and Variations.


Variations

This callback will always be called when any python code registers the variations.
Users can register a new callback as shown below. The "v" object is an Atoms.Variations object, you can get the agent type names as shown below.
from Atoms.constants import JSON_KEYS, JSON_VERSION, VARIATION_CALLBACKS

def cbk(v):
    print(v.getAgentTypeNames())
   
VARIATION_CALLBACKS.append(cbk)

Agent Types and Animation Clips

This callbacks will always be called when any python code registers an animation clip or agent type.
The callback arguments are: the event name, the actions (0 for deletion, 1 for registration) and the SimulationEvent python object for the registered asset. The latter is an object of the classes that you can see when creating a new AgentType or Animation Clip in script mode instead of GUI mode.
Atoms updates all the scripts in the scenes automatically, so you should get this being called straight away.
from Atoms.constants import EVENT_TYPES, ASSET_CALLBACKS

def cbk(name, action, asset):
    print(name, action, asset)
   
def at_cbk(name, action, asset):
    print(name, action, asset)
   
ASSET_CALLBACKS[EVENT_TYPES.ANIMATION_CLIP_EVENT] = [cbk]  
ASSET_CALLBACKS[EVENT_TYPES.AGENT_TYPE_EVENT] = [at_cbk]
    

Copyright © 2017, Toolchefs LTD.