Take for example the following snippet

func _ready():
	v2_screensize = get_viewport_rect().size
	print(v2_screensize)
	print(v2_screensize.y)
	print(v2_screensize[1])

The output:

(1024, 600)
600
600

I'm coming from a PHP background where I can always print_r out on an object or an array and completely see everything that is contained with in it. For example

<?php
print_r(v2_screensize);

Might give me an output that looks like:


v2_screensize:
	[0] = 1024
	[1] = 600
	x = 1024
	y = 600

Is it possible for me to be able to achieve this with Godot? I'm getting a bit overwhelmed clicking around in the Godot documentation inside of the editor trying to discover all of the built in properties and methods on my objects due the inheritance that is happening. I just spent 10 minutes trying to discover that I should use .y and not .height which conflicts with an older tutorial I am using.

Also, any other tips to help me progress along would be terrific.

I do not think there is anything built in that prints all of the properties, but in theory, you can use get_property_list and then print each property and its value manually. Something like (untested):

func print_all_properties():
	print ("\nNode Property List for node: ", name)
	var property_list = get_property_list()
	for prop in property_list:
		print (prop.name, get(prop.name))
	print("\n")

@TwistedTwigleg said: I do not think there is anything built in that prints all of the properties, but in theory, you can use get_property_list and then print each property and its value manually. Something like (untested):

func print_all_properties():
	print ("\nNode Property List for node: ", name)
	var property_list = get_property_list()
	for prop in property_list:
		print (prop.name, get(prop.name))
	print("\n")

Thank you!

Is it possible for me to save that in a script and 'include' it in various scripts in my projects? Or would I always need to declare that in the local script to be able to access it?

You could put it in an Autoload script and then access it that way. For example, if you named the auto load “Utils”:

Utils.print_all_properties(this)

Then you’d just need to adjust the function so it takes a node as input:

 func print_all_properties(input_node):
	print ("\nNode Property List for node: ", input_node.name)
	var property_list = input_node.get_property_list()
	for prop in property_list:
		print (prop.name, get(prop.name))
	print("\n")
2 years later