Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Godot 4 #1

Merged
merged 5 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Example/Texture.gd
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
extends TextureRect

var rect_data: Dictionary
var rect_data: RegionUnpacker.RectData

# roughly 665886 with old imp
func _on_Button_pressed() -> void:
var time = Time.get_ticks_usec()
var unpak := RegionUnpacker.new(10, 3)
rect_data = unpak.get_used_rects(texture.get_data())
$Control.show_preview(rect_data["rects"])
rect_data = unpak.get_used_rects(texture.get_image())
$Control.show_preview(rect_data.rects)
print(Time.get_ticks_usec() - time)



func _on_Texture_item_rect_changed() -> void:
if "rects" in rect_data.keys():
$Control.show_preview(rect_data["rects"])
if is_instance_valid(rect_data) and not rect_data.rects.is_empty():
$Control.show_preview(rect_data.rects)
52 changes: 36 additions & 16 deletions Example/Texture.tscn
Original file line number Diff line number Diff line change
@@ -1,27 +1,47 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=4 format=3 uid="uid://d35eiq1krfqyk"]

[ext_resource path="res://Example/Texture.gd" type="Script" id=1]
[ext_resource path="res://Example/example sheet.png" type="Texture" id=2]
[ext_resource path="res://addons/SmartSlicer/SmartSlicePreview.gd" type="Script" id=3]
[ext_resource type="Script" path="res://Example/Texture.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://bwh16a5td5gwe" path="res://Example/example sheet.png" id="2"]
[ext_resource type="Script" path="res://addons/SmartSlicer/SmartSlicePreview.gd" id="3"]

[node name="Texture" type="TextureRect"]
[node name="Control" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
texture = ExtResource( 2 )
stretch_mode = 6
script = ExtResource( 1 )
grow_horizontal = 2
grow_vertical = 2

[node name="Control" type="Control" parent="."]
[node name="AspectRatioContainer" type="AspectRatioContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 3 )
offset_right = 1.0
offset_bottom = -2.0
grow_horizontal = 2
grow_vertical = 2
ratio = 1.9912

[node name="Texture" type="TextureRect" parent="AspectRatioContainer"]
layout_mode = 2
texture = ExtResource("2")
stretch_mode = 5
script = ExtResource("1")

[node name="Control" type="Control" parent="AspectRatioContainer/Texture"]
anchors_preset = 0
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource("3")

[node name="Button" type="Button" parent="."]
margin_left = 791.0
margin_top = 495.0
margin_right = 984.0
margin_bottom = 563.0
layout_mode = 0
offset_left = 791.0
offset_top = 495.0
offset_right = 984.0
offset_bottom = 563.0
text = "Slice"

[connection signal="item_rect_changed" from="." to="." method="_on_Texture_item_rect_changed"]
[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"]
[connection signal="item_rect_changed" from="AspectRatioContainer/Texture" to="AspectRatioContainer/Texture" method="_on_Texture_item_rect_changed"]
[connection signal="pressed" from="Button" to="AspectRatioContainer/Texture" method="_on_Button_pressed"]
31 changes: 15 additions & 16 deletions Example/example sheet.png.import
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/example sheet.png-0360b514ecb50cc6e83b9cd009b2aff9.stex"
type="CompressedTexture2D"
uid="uid://bwh16a5td5gwe"
path="res://.godot/imported/example sheet.png-0360b514ecb50cc6e83b9cd009b2aff9.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Example/example sheet.png"
dest_files=[ "res://.import/example sheet.png-0360b514ecb50cc6e83b9cd009b2aff9.stex" ]
dest_files=["res://.godot/imported/example sheet.png-0360b514ecb50cc6e83b9cd009b2aff9.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/hdr_compression=1
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Loading