Update loading demos for 4.0 (#776)

This commit is contained in:
Jonathan Nicholl
2022-12-13 10:51:04 -05:00
committed by GitHub
parent 1b2ce74a39
commit 095beddcb9
133 changed files with 728 additions and 1703 deletions

View File

@@ -4,7 +4,7 @@ An example using a thread to load an image.
Language: GDScript
Renderer: Vulkan Mobile
Renderer: Mobile
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/144

BIN
loading/threads/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://p4sshn67o4v6"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.png"
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
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/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -14,7 +14,13 @@ config/name="Loading in a Thread"
config/description="An example using a thread to load an image."
run/main_scene="res://thread.tscn"
config/features=PackedStringArray("4.0")
run/low_processor_mode=true
config/icon="res://icon.png"
[display]
window/vsync/vsync_mode=0
[rendering]
vulkan/rendering/back_end=1
renderer/rendering_method="mobile"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 104 KiB

View File

@@ -1,7 +1,9 @@
extends Node2D
extends Control
var thread: Thread
func _on_load_pressed():
if is_instance_valid(thread) and thread.is_started():
# If a thread is already running, let it finish before we start another.
@@ -26,9 +28,9 @@ func _bg_load_done():
# Wait for the thread to complete, and get the returned value.
var tex = thread.wait_to_finish()
print("THREAD FINISHED!")
$Sprite2D.set_texture(tex)
$TextureRect.texture = tex
# We're done with the thread now, so we can free it.
thread = null # Threads are reference counted, so this is how we free it.
thread = null # Threads are reference counted, so this is how we free them.
func _exit_tree():

View File

@@ -2,23 +2,35 @@
[ext_resource type="Script" path="res://thread.gd" id="1"]
[node name="Thread" type="Node2D"]
[node name="Thread" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1")
[node name="Load" type="Button" parent="."]
offset_left = 432.0
offset_top = 82.0
offset_right = 560.0
offset_bottom = 114.0
layout_mode = 1
anchors_preset = -1
anchor_left = 0.4
anchor_top = 0.15
anchor_right = 0.6
anchor_bottom = 0.2
size_flags_horizontal = 2
size_flags_vertical = 2
text = "Load in Thread"
[node name="Sprite2D" type="Sprite2D" parent="."]
position = Vector2(494, 336)
[node name="Camera2D" type="Camera2D" parent="."]
offset = Vector2(512, 300)
current = true
[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
grow_horizontal = 2
grow_vertical = 2
stretch_mode = 5
[connection signal="pressed" from="Load" to="." method="_on_load_pressed"]