Now the uv preview will show the mesh data instance's active texture as a background.

This commit is contained in:
Relintai 2022-01-20 00:21:23 +01:00
parent b2e6c037f4
commit 1f48d44a5f
4 changed files with 22 additions and 7 deletions

View File

@ -3,16 +3,20 @@ extends Control
var plugin : EditorPlugin
export var uv_editor_path : NodePath
export var uv_preview_path : NodePath
var uv_editor : Node
var uv_preview : Node
func _enter_tree():
uv_editor = get_node(uv_editor_path)
uv_preview = get_node(uv_preview_path)
func set_mesh_data_resource(a : MeshDataResource) -> void:
if uv_editor:
uv_editor.set_mesh_data_resource(a)
if uv_preview:
uv_preview.set_mesh_data_resource(a)
func set_mesh_data_instance(a : MeshDataInstance) -> void:
if uv_preview:
uv_preview.set_mesh_data_instance(a)
func _unhandled_key_input(event : InputEventKey) -> void:
if event.echo:

View File

@ -12,7 +12,7 @@ script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
uv_editor_path = NodePath("VBoxContainer/ScrollContainer/VBoxContainer2/Operations/Operations/UVDisplay")
uv_preview_path = NodePath("VBoxContainer/ScrollContainer/VBoxContainer2/Operations/Operations/UVDisplay")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
margin_left = 7.0

View File

@ -2,6 +2,7 @@ tool
extends Control
var mesh_data_resource : MeshDataResource = null setget set_mesh_data_resource
var background_texture : Texture = null
func set_mesh_data_resource(a : MeshDataResource):
if mesh_data_resource:
@ -14,10 +15,19 @@ func set_mesh_data_resource(a : MeshDataResource):
update()
func set_mesh_data_instance(a : MeshDataInstance):
if !a:
background_texture = null
background_texture = a.texture
func on_mdr_changed():
update()
func _draw():
if background_texture:
draw_texture_rect_region(background_texture, Rect2(Vector2(), get_size()), Rect2(Vector2(), background_texture.get_size()))
if !mesh_data_resource:
return

View File

@ -63,6 +63,7 @@ func edit(object):
if mdi:
mdi_ed_gui.set_mesh_data_resource(mdi.mesh_data)
mdi_ed_gui.set_mesh_data_instance(mdi)
func make_visible(visible):
#print("make_visible")