dollar_node_paths.gd 455 B

1234567891011121314151617181920
  1. extends Node
  2. func test():
  3. # Create the required node structure.
  4. var hello = Node.new()
  5. hello.name = "Hello"
  6. add_child(hello)
  7. var world = Node.new()
  8. world.name = "World"
  9. hello.add_child(world)
  10. # All the ways of writing node paths below with the `$` operator are valid.
  11. # Results are assigned to variables to avoid warnings.
  12. var __ = $Hello
  13. __ = $"Hello"
  14. __ = $Hello/World
  15. __ = $"Hello/World"
  16. __ = $"Hello/.."
  17. __ = $"Hello/../Hello/World"