Skip to content

UPath (Unity Path Language)

Yevhen edited this page Nov 11, 2018 · 8 revisions

UPath gives ability to find a GameObject with more complex expression, with more complex dependencies.

## Structure of expression:

Every expression is started from "/{rootName}", so it will be first element that we are looking for. This element should be active. Next elements that will be searching for, will be under the root element in the hierarchy. Additional: you can't use contains() or [<property>] when describe root element.

Then you clarify name of GameObject that should be found next => "//nextGameObjectName". Note: you can clarify additional property of the GameObject with "[]".

If you don't specify any property for the GameObject, than the Driver will find first occurrence and further search will do against this GameObject. contains(partialName) - it is allowed to use partOfName instead of fullName to have easier locators. You can use them in searching part and in properties part (more detailed see further).

## Types of search:

"//{name}" - Find child or grandchild. Example: "//nameOfGameObject" - find child or grandchild with name "nameOfGameObject"

"/{name}" - Find child. Example: "/nameOfGameObject" - find child with name "nameOfGameObject"

"/.." - Take parent. Example: "/currentGameObject/.." - take parent of GameObject with name "currentGameObject"

"/parent::{name}" - Find parent. Exampe: "/parent::nameOfGameObject" - take parent of GameObject with name "nameOfGameObject"

"/ancestor::{name}" - Find parent or grandparent. Exampe: "/ancestor::nameOfGameObject" - take parent or grandparent of GameObject with name "nameOfGameObject"

"/child::{name}" - Find child. Example: "/child::nameOfGameObject" - take child of GameObject with name "nameOfGameObject"

"/descendant::{name}" - Find child or grandchild. Example: "/descendant::nameOfGameObject" - take child or grandchild of GameObject with name "nameOfGameObject"

## Properties:

You can clarify additional property of searched GameObject with "[]" after the name of the gameObject.

[number] - index of searched GameObject. Example: "/gameObjectName[1]" - will find all gameObjects with name "gameObjectName" and take gameObject with index 1 in the collection.

[axe::{name}] - gameObject should have relation with gameObject in property according to Axe (parent, child, ancestor, descendant). Example: "/gameObjectName[parent::parentName]" - will find gameObjects with name "gameObjectName" and take first that has parent with name "parentName"t with name "parentName"

[active] - gameObject should be active in hierarchy. Example: "/gameObjectName[active]" will find gameObjects with name "gameObjectName" and take first that is active in hierarchy

[!active] - gameObject should be inactive in hierarchy. Example: "/gameObjectName[!active]" will find gameObjects with name "gameObjectName" and take first that is inactive in hierarchy

Note: you can combine index and condition in one UPath. Example: "/gameObjectName[active][1]" will find gameObjects with name "gameObjectName" and that are active in hierarchy and will take gameObject with index 1 in the collection

Clone this wiki locally