Open Invertex opened 2 days ago
@Invertex Hello, thanks for your question!
I can't reproduce this locally, the plugin handles it correctly:
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)
preprocessed to:
func _init() -> void:
pass
Which Godot version are you using: 4.2.2 stable or 4.3 beta 2? If the latter, then I should update the documentation, since the default export mode in 4.3 (Binary Tokens) is not compatible with the plugin.
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?
Directives can work inside functions too, although they were not intended for this purpose. It is not obvious that directives must start at the beginning of the line, indentation is not currently supported. See #7 for details.
Ah yes, I am using 4.3-beta2. That is a shame it doesn't work with the tokenization option, I assume there's no way to hook into the compilation pipeline before it starts the tokenization process?
When I build in "string mode" in 4.3, some plugins don't seem to compile well yet work fine when tokenization is one, so string isn't really an option, and I'd prefer not to use it for the sake of helping protect my code from casual deconstruction.
Thanks for the response and clarification on that though!
I have a simple example, where my class derives from Resource.
It has a function like this:
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!