Get all nodes by name

Get all nodes by name
0

Hello again,

I am using the following code to get a single node:

const p: cc.Node = cc.find("p");

The problem here that I have more than one node named “p”.
Wht I need is to get multiple nodes by name like this:

const p: Array<cc.Node> = cc.find("p");

Of course this is not working. So how can I achive this?

I think all you can do is iterate all the nodes in the scene and check their name.

Yes I am already doing this… However it is bad for performance.
I thout that there is some sort of cached indexing operation like in unity that can get all node by name from a some sort of Dictionary<name, Array>