In order to do debugging I’m trying to display in the scene all the scene variables, with their names and their values. I’m looking for an automatic method, one which doesn’t require me to specify the name of the variables, because I’m constantly changing the names and the number of scene variables, so it is impractical to write and keep updated each variable.
Is it possible?
Maybe something like:
for each scene variable >> add to text VariableName + " " + Variable
Without having the game of the variable I wouldn’t see a way to display it…!
Except if the variable are children of a main variable, you can then ask the text object to display the Json string of “mainvariable”. It would display all children.
In your case the easiest way might be to open preview with debugger. Did you try it? Gdevelop had a debugger showing all variables. Very useful.
Top level variable names are references and cannot be iterated as strings.
However, the debugger already shows you all variables. Why not just use the debugger to check?
Ok, for some reason I didn’t think about the integrated debugger. I didn’t know it existed but I would have thought “surely it exist” and found it in 1 minute. Thanks for pointing it out.
Now that I think about “why should I not use it” I have 2 thoughts:
- I don’t know how it works. I will learn it, but honestly if I had what I asked I didn’t have the necessity of learning how to use the the debugger.
- I want to see the variables in the exported developer build. I sometimes experience bugs on mobile, and the variables on screen makes me understand where the problem is.
That said I understand I’m asking for something which isn’t there. I’ll go document myself on the debugger, thanks again.
Outside of the integrated debugger, the closest you’re going to be able to get is if you put all of your variables as children of a structure variable.
So if you have a scene variable that is named “SceneVar”, which is a structure, then set up all of your other scene variables as children, you can use the “For each child variable” event to loop through them.