I have a scene as such:
where the main scene has a show_title
variable and before I export the game I run the following plugin:
tool
extends EditorExportPlugin
class_name CustomExportPlugin
func _export_begin(features, is_debug, path, flags):
# do some checks before exporting
...
How do I set the show_title=true
within the Main.tscn
every time before exporting?
Note: I am using godot version 3.5
Modifying an scene from a
tool
scriptYou
load
the scene.You
instance
it (instantiate
in Godot 4).You modify the instance:
You package it again:
And save it:
Yes, this modifies the project. And no,
EditorExportPlugin
IN GODOT 3, does not make this any easier.IN GODOT 4 you can override
_begin_customize_resources
to return true, and override_customize_resource
to return the modifiedPackedScene
. This way you don't have to save it, and thus the project is not modified.What I would do
In the script on the root of
main.tscn
:If you need this set before
_ready
, you can do it in_init
instead.If that script is not a tool script, that won't happen in the editor. If it is, then you can check if the code is running in the editor with
Engine.editor_hint
(Engine.is_editor_hint()
in Godot 4).