Can I use the same ActionManager instance on different meshes?


So I noticed that when I’m using the same ActionManager on each of the meshes, the action is triggered on all meshes. Does this mean I have to use a new ActionManager instance per mesh?

Here’s the example with shared ActionManager:

And here’s what I want to have (new ActionManager per mesh):

You can, but you have to check which mesh is under pointer and get reference to its material.

Note that even though visually this works, event will trigger twice. Basically, each time you call addAction you register the same action to actionManager (note that it is one actionManager, but you are registering multiple actions to it. So if you have like 10 spheres, hovering over one of those will trigger same action 10 times).

You need to register this action only once though, and you can do it once you create actionManager. With these changes method addAction becomes setMaterial pretty much. This will ensure that you trigger the event only once per hover.