[quote=“thebluefish”]How about:
Node* GetChild(const String& name, bool recursive = false) const;
Something like this should work:
Urho3D::String name("Object");
Urho3D::String newName(name);
Urho3D::Node* node = parentNode->GetChild(name, true);
for (int x = 1; node; x++)
{
newName = name.Append(x);
node = parentNode->GetChild(newName, true);
}
node = parentNode->CreateChild(newName);
Edit: Just want to point out that this is horribly inefficient in that it will take longer the more nodes you have. It simply doesn’t scale well. If I were serious about object management, I would probably create a component that actively tracks when nodes are created/removed and automatically renames a node if it detects a naming conflict. By tracking the name IDs in your naming scheme, there wouldn’t be additional overhead regardless of how many nodes with the same naming scheme exist, at the cost of a little memory overhead.[/quote]
Hmmm. I have a manager that tracks createdobjects so technically I can search through that for naming conflicts.
Because, objects can be retrieved from a network, or other node files with children. I think any method would be highly inefficient.