QUERY SYSTEM

You can use the query system to search for specific nodes inside your layout.

NOTE: You can find examples about running queries in the Example_QuerySystem abd Example_QuerySystem2 scenes in the Examples folder.


Enabling the Query System

Query System must be enabled di checking the Use Query System flag inside the Layout inspector.

After turning on this flag, a RadialLayoutQueryTarget component will be added to each node and an uniqueId will be assigned to each of them.

IMPORTANT: Only nodes with the RadialLayoutQueryTarget will be considered when running a query.


What can be searched for

The query system can be used to search for the following elements:

  • Nodes
  • Layouts
  • Links

Searches can be:

  • Based on the UniqueID assigned to a node.
  • Based on speficic Tags

NOTE: Links can be looked for using generating or targeted nodes.


The RadialLayoutQueryResult class

Every query will return a RadialLayoutQueryResult object containing the results, contained in three different lists:

  1. Nodes
  2. Links
  3. Layouts

You can run query functions over the previous RadialLayoutQueryResult to create chained queries for advanced searches, for example:


var result = RadialLayoutQueryManager.Begin(layout).GetNodesWithTags("abilities").GetNodesWithTags("secondary");

Will first search for all nodes tagged "abilities", and run a "secondary" tag search over the first result.


Starting a Query

Every query starts with the Begin() function over the target layout:


RadialLayoutQueryManager.Begin(layout)

this will "open" the query for subsequent calls:


var allNodes = RadialLayoutQueryManager.Begin(layout).GetAllNodes();


Supported searches

This is a list of every search function available:

  • GetAllNodes
  • GetNodeResultWithUniqueId
  • GetNodeWithUniqueId (this will return the RadialLayoutNode directly, instead of a RadialLayoutQueryResult object)
  • GetNodesWithTags
  • GetAllLayouts
  • GetLayoutsWithTags
  • GetAllLinks
  • GetLinkConnecting
  • GetLinksStartingFrom
  • GetLinksGoingTo

Logical Operators

You can combine results with logical operators:


var all_nodes = RadialLayoutQueryManager.Begin(this.layout).GetAllNodes();

var result_1 = RadialLayoutQueryManager.Begin(this.layout).GetNodesWithTags("red");

var result_2 = RadialLayoutQueryManager.Begin(this.layout).GetNodesWithTags("black");



result = result_1 | result_2;  // red OR black nodes

result = result_1 + result_2;  // same as above

result = result_1 & result_2;  // red AND black nodes

result = all_nodes - result_1; // all nodes except red