Amerio.Stephane Posted July 2, 2023 Posted July 2, 2023 Hi, is there a easy or preferred way to retrieve all components or all node with a type of component? Even if this is slow. The alternative would be to store all components at creation time, but there may already exist an easier way to do that?
cash-metall Posted July 3, 2023 Posted July 3, 2023 Hello! template <class T> void collectAllComponents(Unigine::Vector<T *> &out_components) { Unigine::Vector<Unigine::NodePtr> root_nodes; Unigine::World::getRootNodes(root_nodes); for (auto & it : root_nodes) Unigine::ComponentSystem::get()->getComponentsInChildren<T>(it, out_components, false); } // usage example Unigine::Vector<MyComponent *> components; collectAllComponents(components); 1
Recommended Posts