Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getComponentByName(parent_object, component_name) {
- if ((parent_object == null) || (component_name == null)) return null;
- var cnt = parent_object.children.length;
- //console.log("parent has ",cnt," children");
- for (var i=0; i<cnt; i++) {
- var sub_object = parent_object.children[i];
- //console.log("Child[",i,"] name=[",sub_object.objectName,"]");
- if (sub_object.objectName === component_name) {
- //console.log("Found [",component_name,"] !");
- return sub_object;
- }
- //make some recursion
- if (sub_object.children.length > 0) {
- var sub_child = getComponentByName(sub_object, component_name);
- if (sub_child != null) {
- console.log("got sub_child ",sub_child);
- return sub_child;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement