Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AY-2218_Plugin hooks - Loader and Scene Inventory #928

Open
ynbot opened this issue Oct 1, 2024 · 0 comments
Open

AY-2218_Plugin hooks - Loader and Scene Inventory #928

ynbot opened this issue Oct 1, 2024 · 0 comments
Assignees
Labels
sponsored This is directly sponsored by a client or community member type: enhancement Improvement of existing functionality or minor addition

Comments

@ynbot
Copy link
Contributor

ynbot commented Oct 1, 2024

Plugin hooks 🪝

Extending or changing functionality in current plugin system is difficult as extending classes of loaders or actions create dependency between any custom code and the plugin functionality. If the loader changes, all custom modifications can break down the line.

Hook system provides entry points for arbitrary code to run upon plugin execution without binding it to the code of the plugin itself. For example:

Loader that is loading model from OBJ file in Maya. That loader will invoke some Maya logic to load the actual format and it will containerize the data in Maya so it can be version controled. But what if studio wants to do something else with loaded data - what if it wants to alway apply some transformation, or automatically assign some default shader, fill some metadata somewhere?

Currently, the only way would be to create new loader inheriting the original one (but with that you would need to solve import issues), you would probably need to fork maya addon repo. Or you could change the logic directly, or you could duplicate the code into your loader in your studio addon and somehow disable the original one.

All this is supercumbersome and it is solved by hooks.

Captain Hook 🚢

Hooks are scripts that can be executed within some context on certain time. Registering hooks and executing them is sort of plugin system. In case of Loader and Actions execution point in time is probably "before load" and "after load" and something needs to be passed to the hook to make it useful (probably runtime content of arguments passed to load())

You should be able to register your hooks to execution point in time and specific plugin. So back to the example above: lets say the OBJ loader class is LoadObj. I have hook called "assign_shader_to_obj" that is implemented in some hook class with some entry point method. I register my hook by calling AYON API that passes the hook object itself, the loader class name and "the execution time type" and when this loader is run, it will execute my hook.

This issue was automatically created from Clickup ticket AY-2218

@ynbot ynbot added sponsored This is directly sponsored by a client or community member type: enhancement Improvement of existing functionality or minor addition labels Oct 1, 2024
@mkolar mkolar assigned kalisp and unassigned antirotor Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sponsored This is directly sponsored by a client or community member type: enhancement Improvement of existing functionality or minor addition
Projects
None yet
Development

No branches or pull requests

3 participants