I have a function that takes as input an instance of any object. Based on the plugin of the instance itself (Sprite, SVG, 9Patch, Text...) i want to perform certain different actions. Given an instance, how can i get its plugin back (using scripting, not normal events)?
Here's an example of what I want to do:
const spriteInstance = runtime.objects.player.getFirstPickedInstance();
const svgInstance = runtime.objects.circle.getFirstPickedInstance();
const textInstance = runtime.objects.title.getFirstPickedInstance();
function performAction(instance) {
if(getPlugin(instance) == "Sprite") console.log("This is a sprite");
if(getPlugin(instance) == "SVG") console.log("This is a SVG object");
if(getPlugin(instance) == "Text") console.log("This is a text object");
}
performAction(spriteInstance);
performAction(svgInstance);
performAction(textInstance);