I notice during debugging sometimes variables value cannot be inspect i am guessing is due to variable optimization?
For example,
var temp = somecalc()
Sometimes if temp is not used then during debug trace temp's value cannot be inspect, to make it inspectable I have to add a dummy variable to hold temp
var temp = somecalc()
var temp2 = temp
Is there a setting to always show unused variables values during debug?
- Edited
- Best Answerset by newguy
Generally, if you have a variable that may not be used, you should proceed it with an underscore ( _ ). This bypasses the "unused_variable" error too. You also get the added bonus of it popping up first whenever the editor is showing options for autofill.
If you are having trouble, you can use:
export var temp = someCalc()
And then it will appear in the Inpsector as well.
However, whenever I need to see a variable during testing/building, I usually build my own debug function into an input somewhere. Something like:
func _debugger():
if Input.is_action_just_pressed("debug"):
print(str(yourVariableHere))
func _input(_event):
_debugger()
And I'll fiddle with that until I know my code is doing what I want.
SnapCracklins Thanks for the info!