New script attributes > Array: true

Hi,

I’ve been developing and rewriting some of our scripts and I noticed, that with the new script attributes it is possible to have an array of strings, while that is nice and saves me the struggle of parsing through a comma separated string to get several values,
it would be super awesome if this would also be possible for entities … it could basically look absolutely the same as the string array, all I need is to be able to do is to fill several entities into one attribute, so that I can trigger a certain event on all of them at once.

Is this something that could be possible?
Did I just not declare my attribute right

TriggerClick.attributes.add('actions', { type: 'entity', title: 'Actions: ', default: [], array: true, description: "The actions which should be triggered when the object is clicked."});

or is it something you guys could add to the engine?

It would really help a lot as it is something me and my colleague have been struggling with since we started using PlayCanvas and something we always had to find workarounds for.

If in the future all attribute types could be an array or not that would of course be the best, but if for now entities could be… :innocent:

Hey.

Yeah, so new format using array: true is meant to be implemented for all attribute types, but for now it really is only available for assets, even strings - is not really an array, but a set, where you can’t change order nor can have duplicates.

Plan is to add support for multiple values for other types indeed, it is in backlog, can’t really give an ETA.

Regarding entities case, you could look into tagging - that could work in some cases.

Hey, this post is over a year old. Has any progress been made on this front? I’m just wondering if it is now possible to have an array of entities?

Unfortunately, no.

There are ways to get around this (eg. using the event system and keeping an internal list) but it’s not ideal :frowning:

Figured as much. I ended up simply using Entity.findByTag; it returns an array of all matching entities.

Any plan to add this feature?

I think so eventually but it’s not currently in our priorities.