Hierarchy.FindTransformByPath Method (Transform,String[], Transform) |
Namespace: KSPDev.ModelUtils
public static Transform FindTransformByPath( Transform parent, string[] path, Transform defValue = null )
All patterns except ** may have a matching index. It can be used to resolve matches when there are multiple objects found with the same name and at the same level. E.g. if there are two objects with name "a" at the root level then the first one can be accessed by pattern a:0, and the second one by pattern a:1.
Path search is slow since it needs walking though the hierarchy nodes. In the worst case all the nodes will be visited. Don't use this method in the performance demanding methods.
// a // + b // | + c // | | + c1 // | | + d // | + c // | + d // | + e // | + e1 // + abc
Here are some matching examples:
// a/b/c/d/e/e1 => a/b/c/d/e/e1 // a/b/c/c1 => a/b/c/c1 // a/b/*/d/e/e1 => a/b/c/d/e/e1 // a/b/*/*/e/e1 => a/b/c/d/e/e1 // a/b/* => a/b/c, branch a/b/c/c1/d (the first match) // a/b/*:0 => a/b/c, branch a/b/c/c1/d // a/b/*:1 => a/b/c, branch a/b/c/d/e/e1 // a/b/c:1/d => a/b/c/d, branch a/b/c/d/e/e1 // **/e1 => a/b/c/d/e/e1 // **/c1 => a/b/c/c1 // **/c/d => a/b/c/d, branch a/b/c/d // **/*c => a/abc. The other matched branch (a/b/c) will be refused due to the length. // a/**/e1 => a/b/c/d/e/e1 // *bc => a/abc // ab* => a/abc // *b* => a/abc