Skip to content

UPath (Unity Path Language)

Yevhen edited this page Nov 6, 2018 · 8 revisions

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

First element will be define as root element and it should be active. All futher search is started from the element.

## Structure of expression:

Every expression is started from "//" or "/", so it means that your next element is strictly child (if single slash) or child and grandchild (if double slash) of "Main Canvas" 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.

## 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