Implement selecting the edited resource on clicking it's button in the world generator addon's EditorResourceWidget.

This commit is contained in:
Relintai 2022-03-08 18:12:11 +01:00
parent c2e2fe2a5f
commit ecdfb65aa7
3 changed files with 7 additions and 6 deletions

View File

@ -53,6 +53,7 @@ func add_slot_resource(getter : String, setter : String, slot_name : String, res
bc.add_child(l)
var r : Control = EditorResourceWidget.instance()
r.set_plugin(_plugin)
r.set_resource_type(resource_type)
r.set_resource(_edited_resource.call(getter))
r.set_h_size_flags(SIZE_EXPAND_FILL)

View File

@ -3,6 +3,7 @@ extends HBoxContainer
var _resource_type : String = "Resource"
var _resource : Resource = null
var _plugin : EditorPlugin = null
signal on_resource_changed(new_res)
@ -41,9 +42,8 @@ func on_clear_button_pressed() -> void:
set_resource(null)
func on_resource_button_pressed() -> void:
if _resource:
#todo
pass
if _resource && _plugin:
_plugin.get_editor_interface().inspect_object(_resource)
#examples
#{files:[res://modules/planets/test_planet/test_world.tres], from:@@4176:[Tree:9070], type:files}
@ -75,3 +75,6 @@ func get_drag_data_fw(position, from_control):
d["type"] = "resource"
return d
func set_plugin(plugin : EditorPlugin) -> void:
_plugin = plugin

View File

@ -6,9 +6,6 @@
margin_right = 376.0
margin_bottom = 40.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ResourceButton" type="Button" parent="."]
margin_right = 342.0