getDepth method

int getDepth()

Returns the depth of this node in the scene graph hierarchy. The root node has a depth of 0.

Implementation

int getDepth() {
  int depth = 0;
  Node? current = this;
  while (current!._parent != null) {
    current = current._parent;
    depth++;
  }
  return depth;
}