From 74b35246c821eeb2f9a53a94b5d4d17b534f53f0 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 13 Sep 2021 12:32:33 +0200 Subject: [PATCH] Now the mesh data resource addon actually shows uvs in the uv editor. --- game/addons/mesh_data_resource_editor/MDIEd.gd | 6 +++++- .../mesh_data_resource_editor/UVEditor.gd | 5 +++-- game/addons/mesh_data_resource_editor/plugin.gd | 17 ++++++++++++----- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/game/addons/mesh_data_resource_editor/MDIEd.gd b/game/addons/mesh_data_resource_editor/MDIEd.gd index 2a01baa5..9bb02d07 100644 --- a/game/addons/mesh_data_resource_editor/MDIEd.gd +++ b/game/addons/mesh_data_resource_editor/MDIEd.gd @@ -7,8 +7,12 @@ export var uv_editor_path : NodePath var uv_editor : Node -func _init(): +func _enter_tree(): uv_editor = get_node(uv_editor_path) + +func set_mesh_data_resource(a : MeshDataResource) -> void: + if uv_editor: + uv_editor.set_mesh_data_resource(a) func _unhandled_key_input(event : InputEventKey) -> void: if event.echo: diff --git a/game/addons/mesh_data_resource_editor/UVEditor.gd b/game/addons/mesh_data_resource_editor/UVEditor.gd index 4876d656..c4099060 100644 --- a/game/addons/mesh_data_resource_editor/UVEditor.gd +++ b/game/addons/mesh_data_resource_editor/UVEditor.gd @@ -3,7 +3,7 @@ extends Control var mesh_data_resource : MeshDataResource = null setget set_mesh_data_resource -func set_mesh_data_resource(a): +func set_mesh_data_resource(a : MeshDataResource): if mesh_data_resource: mesh_data_resource.disconnect("changed", self, "on_mdr_changed") @@ -11,7 +11,7 @@ func set_mesh_data_resource(a): if mesh_data_resource: mesh_data_resource.connect("changed", self, "on_mdr_changed") - + update() func on_mdr_changed(): @@ -31,3 +31,4 @@ func _draw(): draw_line(uvs[indices[i + 2]] * get_size(), uvs[indices[i]] * get_size(), Color(1, 1, 1, 1), 1, false) + diff --git a/game/addons/mesh_data_resource_editor/plugin.gd b/game/addons/mesh_data_resource_editor/plugin.gd index da86a350..56494a38 100644 --- a/game/addons/mesh_data_resource_editor/plugin.gd +++ b/game/addons/mesh_data_resource_editor/plugin.gd @@ -10,7 +10,7 @@ var mdi_ed_gui : Control var active_gizmos : Array func _enter_tree(): - print("_enter_tree") + #print("_enter_tree") gizmo_plugin = MdiGizmoPlugin.new() mdi_ed_gui = MDIEdGui.instance() @@ -27,7 +27,7 @@ func _enter_tree(): set_input_event_forwarding_always_enabled() func _exit_tree(): - print("_exit_tree") + #print("_exit_tree") remove_spatial_gizmo_plugin(gizmo_plugin) #remove_control_from_container(EditorPlugin.CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT, mdi_ed_gui) @@ -45,15 +45,21 @@ func _exit_tree(): # mdi_ed_gui.queue_free() func handles(object): - print("disable_plugin") + #print("disable_plugin") if object is MeshDataInstance: return true return false + +func edit(object): + var mdi : MeshDataInstance = object as MeshDataInstance + if mdi: + mdi_ed_gui.set_mesh_data_resource(mdi.mesh_data) + func make_visible(visible): - print("make_visible") + #print("make_visible") if visible: mdi_ed_gui.show() @@ -61,9 +67,10 @@ func make_visible(visible): #mdi_ed_gui.hide() #figure out how to hide it when something else gets selected, don't hide on unselect pass - + func get_plugin_name(): return "mesh_data_resource_editor" + #func forward_spatial_gui_input(camera, event): # return forward_spatial_gui_input(0, camera, event)