2025-12-29 11:54:31 +08:00
|
|
|
|
@tool
|
|
|
|
|
|
extends EditorPlugin
|
2025-12-31 13:07:31 +08:00
|
|
|
|
|
2026-01-01 16:33:32 +08:00
|
|
|
|
var inspector_plugins: Array[EditorInspectorPlugin] = []
|
|
|
|
|
|
|
|
|
|
|
|
const AUTOLOAD_REED_SCENE_NAME: StringName = "ReedSceneSystem"
|
|
|
|
|
|
const AUTOLOAD_REED_SCENE_PATH:= "res://addons/reedscene/scene/SceneRegistry.gd"
|
|
|
|
|
|
|
|
|
|
|
|
var toolbar_button: Button
|
|
|
|
|
|
var scene_id_window: Window
|
|
|
|
|
|
var main_screen: Control
|
2025-12-31 13:07:31 +08:00
|
|
|
|
|
|
|
|
|
|
func _enter_tree() -> void:
|
2026-01-01 16:33:32 +08:00
|
|
|
|
_load_mainscreen()
|
|
|
|
|
|
|
|
|
|
|
|
if not ProjectSettings.has_setting("autoload/%s" % AUTOLOAD_REED_SCENE_NAME):
|
|
|
|
|
|
add_autoload_singleton(AUTOLOAD_REED_SCENE_NAME, AUTOLOAD_REED_SCENE_PATH)
|
|
|
|
|
|
|
|
|
|
|
|
# Inspector 1:你已有的
|
|
|
|
|
|
var act_inspector := preload(
|
|
|
|
|
|
"res://addons/reedscene/act/ActManagerInspector.gd"
|
|
|
|
|
|
).new()
|
|
|
|
|
|
act_inspector.editor_interface = get_editor_interface()
|
|
|
|
|
|
add_inspector_plugin(act_inspector)
|
|
|
|
|
|
inspector_plugins.append(act_inspector)
|
|
|
|
|
|
|
|
|
|
|
|
# Inspector 2:新的(比如 ReedSceneID)
|
|
|
|
|
|
var scene_id_inspector := preload(
|
|
|
|
|
|
"res://addons/reedscene/scene/ReedSceneIDInspector.gd"
|
|
|
|
|
|
).new()
|
|
|
|
|
|
add_inspector_plugin(scene_id_inspector)
|
|
|
|
|
|
inspector_plugins.append(scene_id_inspector)
|
2025-12-31 13:07:31 +08:00
|
|
|
|
|
|
|
|
|
|
func _exit_tree() -> void:
|
2026-01-01 16:33:32 +08:00
|
|
|
|
_unload_mainscreen()
|
|
|
|
|
|
|
|
|
|
|
|
##自动删除单例
|
|
|
|
|
|
if ProjectSettings.has_setting("autoload/%s" % AUTOLOAD_REED_SCENE_NAME):
|
|
|
|
|
|
remove_autoload_singleton(AUTOLOAD_REED_SCENE_NAME)
|
|
|
|
|
|
|
|
|
|
|
|
# 移除 InspectorPlugin
|
|
|
|
|
|
for plugin in inspector_plugins:
|
|
|
|
|
|
remove_inspector_plugin(plugin)
|
|
|
|
|
|
inspector_plugins.clear()
|
|
|
|
|
|
|
|
|
|
|
|
##加載主界面
|
|
|
|
|
|
func _load_mainscreen() -> void:
|
|
|
|
|
|
main_screen = preload("res://addons/reedscene/dock/scene_id_main_screen.tscn").instantiate()
|
|
|
|
|
|
EditorInterface.get_editor_main_screen().add_child(main_screen)
|
|
|
|
|
|
main_screen.visible = false
|
|
|
|
|
|
|
|
|
|
|
|
##卸載主界面
|
|
|
|
|
|
func _unload_mainscreen() -> void:
|
|
|
|
|
|
if main_screen:
|
|
|
|
|
|
main_screen.queue_free()
|
|
|
|
|
|
main_screen = null
|
|
|
|
|
|
|
|
|
|
|
|
func _has_main_screen() -> bool:
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
|
|
func _make_visible(visible: bool) -> void:
|
|
|
|
|
|
if main_screen:
|
|
|
|
|
|
main_screen.visible = visible
|
|
|
|
|
|
|
|
|
|
|
|
func _get_plugin_name() -> String:
|
|
|
|
|
|
return "Reed Scene"
|
|
|
|
|
|
|
|
|
|
|
|
func _get_plugin_icon() -> Texture2D:
|
|
|
|
|
|
return EditorInterface.get_editor_theme().get_icon("Node", "EditorIcons")
|