songtao.han Posted July 1, 2021 Share Posted July 1, 2021 Hi! I've found that if I loaded a node by calling Syncker.Maste.LoadNode method, only the node itself would be added to the synchronization queue, but all its children wouldn't. I'm wondering that if I need to add all the children manually or it could be done automaticlly? Link to comment
cash-metall Posted July 1, 2021 Share Posted July 1, 2021 Hi, songtao.han! This is not a bug, it was done on purpose. For best performance, you need to manually specify which nodes you need to synchronize and specify a mask for each. (usually not all nodes changing at runtime, and there is no point in synchronizing static nodes - it can drop the performance) If you realy need to add all the nodes to synchronization, you can write a simple recursive method void addSyncNodeRecursive(const NodePtr &node, unsigned char mask) { if (!node) return; sync_master->addSyncNode(node, mask); // add current node to sync with mask if (node->getType() == Node::NODE_REFERENCE) // if its nodereference - we need to expand it, and process its reference addSyncNodeRecursive(checked_ptr_cast<NodeReference>(node)->getReference(), mask); for (int i = 0 ; i < node->getNumChildren(); i++) addSyncNodeRecursive(node->getChild(i), mask); // also call this method for each children } // unsinged char mask = ~0; // NodePtr new_node = sync_master->loadNode("mynode.node", mask); // addSyncNodeRecursive(new_node, mask); (it is cpp code, but in c# it will look similar) Link to comment
Recommended Posts