gdscript-preprocessor icon indicating copy to clipboard operation
gdscript-preprocessor copied to clipboard

Conditional block not stripped if there are conditions inside of it?

Open Invertex opened this issue 7 months ago • 2 comments

I have a simple example, where my class derives from Resource.

It has a function like this:

func _init() -> void:
	if Engine.is_editor_hint():
		if type_exists("EditorInterface") and EditorInterface.has_method("get_inspector"):
			var selection = EditorInterface.get_inspector().get_edited_object()
			print(selection.name)

But the exported build is still throwing an error about EditorInterface not existing, meaning that code is still being included. If I don't have that inner condition, then that is_editor_hint() block gets excluded fine, I tried with just print() inside there instead.

Is this feature not supposed to strip everything within the if Engine.is_editor_hint(): conditional block?

I also tried just stripping the function using the #~if OS.has_feature("my_feature") option but I guess it can only strip top-level variables and not functions or code inside of functions?

Thanks!

Invertex avatar Jun 30 '24 15:06 Invertex