@tool extends EditorPlugin ## Polydoodle - a cute little poly modeler. Main screen editor plugin. var _screen: Control func _enter_tree() -> void: _screen = load("res://addons/polydoodle/editor/pd_main.gd").new() _screen.name = "PolydoodleScreen" EditorInterface.get_editor_main_screen().add_child(_screen) _screen.hide() # SAVE SYSTEM: bring back the user's models when the # editor reopens. Deferred: the screen finishes building its views # on ready. _screen.restore_session.call_deferred() func _exit_tree() -> void: # flush the session BEFORE freeing the screen, so closing the # editor (or disabling the plugin) never loses the user's models if is_instance_valid(_screen) and _screen.has_method("persist_session"): _screen.persist_session() if is_instance_valid(_screen): _screen.queue_free() _screen = null func _has_main_screen() -> bool: return true func _get_plugin_name() -> String: return "Polydoodle" func _get_plugin_icon() -> Texture2D: # Godot draws the main-screen tab icon at the texture's NATIVE size # (there is no icon_max_width knob on those tabs), while every built-in # tab (2D / 3D / Script / AssetLib) is a 16 px SVG. Pre-resize to 16 so # the Polydoodle logo matches the native icons exactly. return preload("res://addons/polydoodle/core/pd_icons.gd").get_icon_sized("icon", 16) func _make_visible(visible: bool) -> void: if is_instance_valid(_screen): _screen.visible = visible