瀏覽代碼

Update loading demos for 4.0 (#776)

Jonathan Nicholl 2 年之前
父節點
當前提交
095beddcb9
共有 100 個文件被更改,包括 318 次插入1428 次删除
  1. 1 1
      loading/README.md
  2. 1 1
      loading/autoload/README.md
  3. 13 14
      loading/autoload/global.gd
  4. 4 8
      loading/autoload/project.godot
  5. 2 1
      loading/autoload/scene_a.gd
  6. 7 2
      loading/autoload/scene_a.tscn
  7. 2 1
      loading/autoload/scene_b.gd
  8. 7 5
      loading/autoload/scene_b.tscn
  9. 二進制
      loading/autoload/screenshots/autoload.png
  10. 0 15
      loading/background_load/README.md
  11. 0 64
      loading/background_load/background_load.gd
  12. 0 17
      loading/background_load/background_load.tscn
  13. 0 5
      loading/background_load/paintings.gd
  14. 0 213
      loading/background_load/paintings.tscn
  15. 0 109
      loading/background_load/project.godot
  16. 二進制
      loading/background_load/screenshots/paintings.png
  17. 0 5
      loading/background_load/sculptures.gd
  18. 0 141
      loading/background_load/sculptures.tscn
  19. 二進制
      loading/background_load/sculptures/sculpture_david.jpg
  20. 0 35
      loading/background_load/sculptures/sculpture_david.jpg.import
  21. 二進制
      loading/background_load/sculptures/sculpture_fountain.jpg
  22. 0 35
      loading/background_load/sculptures/sculpture_fountain.jpg.import
  23. 二進制
      loading/background_load/sculptures/sculpture_four_parts_of_earth.jpg
  24. 0 35
      loading/background_load/sculptures/sculpture_four_parts_of_earth.jpg.import
  25. 二進制
      loading/background_load/sculptures/sculpture_lincoln.jpg
  26. 0 35
      loading/background_load/sculptures/sculpture_lincoln.jpg.import
  27. 二進制
      loading/background_load/sculptures/sculpture_thinker.jpg
  28. 0 35
      loading/background_load/sculptures/sculpture_thinker.jpg.import
  29. 二進制
      loading/background_load/sculptures/sculpture_venus.png
  30. 0 35
      loading/background_load/sculptures/sculpture_venus.png.import
  31. 13 0
      loading/load_threaded/README.md
  32. 二進制
      loading/load_threaded/icon.png
  33. 14 15
      loading/load_threaded/icon.png.import
  34. 42 0
      loading/load_threaded/load_threaded.gd
  35. 102 0
      loading/load_threaded/load_threaded.tscn
  36. 0 0
      loading/load_threaded/paintings/painting_babel.jpg
  37. 14 15
      loading/load_threaded/paintings/painting_babel.jpg.import
  38. 二進制
      loading/load_threaded/paintings/painting_las_meninas.png
  39. 14 15
      loading/load_threaded/paintings/painting_las_meninas.png.import
  40. 0 0
      loading/load_threaded/paintings/painting_mona_lisa.jpg
  41. 14 15
      loading/load_threaded/paintings/painting_mona_lisa.jpg.import
  42. 0 0
      loading/load_threaded/paintings/painting_old_guitarist.jpg
  43. 14 15
      loading/load_threaded/paintings/painting_old_guitarist.jpg.import
  44. 0 0
      loading/load_threaded/paintings/painting_parasol.jpg
  45. 14 15
      loading/load_threaded/paintings/painting_parasol.jpg.import
  46. 0 0
      loading/load_threaded/paintings/painting_the_swing.jpg
  47. 14 15
      loading/load_threaded/paintings/painting_the_swing.jpg.import
  48. 26 0
      loading/load_threaded/project.godot
  49. 0 0
      loading/load_threaded/screenshots/.gdignore
  50. 二進制
      loading/load_threaded/screenshots/paintings.png
  51. 0 18
      loading/multiple_threads_loading/README.md
  52. 二進制
      loading/multiple_threads_loading/icon.png
  53. 0 3
      loading/multiple_threads_loading/images/.gitignore
  54. 二進制
      loading/multiple_threads_loading/images/icon_1.png
  55. 二進制
      loading/multiple_threads_loading/images/icon_10.png
  56. 二進制
      loading/multiple_threads_loading/images/icon_11.png
  57. 二進制
      loading/multiple_threads_loading/images/icon_12.png
  58. 二進制
      loading/multiple_threads_loading/images/icon_13.png
  59. 二進制
      loading/multiple_threads_loading/images/icon_14.png
  60. 二進制
      loading/multiple_threads_loading/images/icon_15.png
  61. 二進制
      loading/multiple_threads_loading/images/icon_16.png
  62. 二進制
      loading/multiple_threads_loading/images/icon_17.png
  63. 二進制
      loading/multiple_threads_loading/images/icon_18.png
  64. 二進制
      loading/multiple_threads_loading/images/icon_19.png
  65. 二進制
      loading/multiple_threads_loading/images/icon_2.png
  66. 二進制
      loading/multiple_threads_loading/images/icon_20.png
  67. 二進制
      loading/multiple_threads_loading/images/icon_21.png
  68. 二進制
      loading/multiple_threads_loading/images/icon_22.png
  69. 二進制
      loading/multiple_threads_loading/images/icon_23.png
  70. 二進制
      loading/multiple_threads_loading/images/icon_24.png
  71. 二進制
      loading/multiple_threads_loading/images/icon_25.png
  72. 二進制
      loading/multiple_threads_loading/images/icon_26.png
  73. 二進制
      loading/multiple_threads_loading/images/icon_27.png
  74. 二進制
      loading/multiple_threads_loading/images/icon_28.png
  75. 二進制
      loading/multiple_threads_loading/images/icon_29.png
  76. 二進制
      loading/multiple_threads_loading/images/icon_3.png
  77. 二進制
      loading/multiple_threads_loading/images/icon_30.png
  78. 二進制
      loading/multiple_threads_loading/images/icon_31.png
  79. 二進制
      loading/multiple_threads_loading/images/icon_32.png
  80. 二進制
      loading/multiple_threads_loading/images/icon_33.png
  81. 二進制
      loading/multiple_threads_loading/images/icon_34.png
  82. 二進制
      loading/multiple_threads_loading/images/icon_35.png
  83. 二進制
      loading/multiple_threads_loading/images/icon_36.png
  84. 二進制
      loading/multiple_threads_loading/images/icon_37.png
  85. 二進制
      loading/multiple_threads_loading/images/icon_38.png
  86. 二進制
      loading/multiple_threads_loading/images/icon_39.png
  87. 二進制
      loading/multiple_threads_loading/images/icon_4.png
  88. 二進制
      loading/multiple_threads_loading/images/icon_40.png
  89. 二進制
      loading/multiple_threads_loading/images/icon_5.png
  90. 二進制
      loading/multiple_threads_loading/images/icon_6.png
  91. 二進制
      loading/multiple_threads_loading/images/icon_7.png
  92. 二進制
      loading/multiple_threads_loading/images/icon_8.png
  93. 二進制
      loading/multiple_threads_loading/images/icon_9.png
  94. 0 5
      loading/multiple_threads_loading/link_button.gd
  95. 0 219
      loading/multiple_threads_loading/main.tscn
  96. 0 33
      loading/multiple_threads_loading/preload.gd
  97. 0 65
      loading/multiple_threads_loading/preload.tscn
  98. 0 23
      loading/multiple_threads_loading/project.godot
  99. 0 145
      loading/multiple_threads_loading/resource_queue.gd
  100. 0 0
      loading/multiple_threads_loading/screenshots/.gdignore

+ 1 - 1
loading/README.md

@@ -4,4 +4,4 @@ These demos demonstrate various ways to load scenes and other data.
 
 Languages: All are GDScript
 
-Renderers: All are GLES 2
+Renderers: All are Mobile

+ 1 - 1
loading/autoload/README.md

@@ -4,7 +4,7 @@ This demo shows how to use autoloads to change between scenes.
 
 Language: GDScript
 
-Renderer: Vulkan Mobile
+Renderer: Mobile
 
 Check out this demo on the asset library: https://godotengine.org/asset-library/asset/529
 

+ 13 - 14
loading/autoload/global.gd

@@ -1,10 +1,10 @@
 extends Node
-
-# Changing scenes is most easily done using the functions `change_scene`
-# and `change_scene_to` of the SceneTree. This script demonstrates how to
+# Changing scenes is most easily done using the functions change_scene_to_file
+# and change_scene_to_packed of the SceneTree. This script demonstrates how to
 # change scenes without those helpers.
 
-func goto_scene(path):
+
+func goto_scene(path: String):
 	# This function will usually be called from a signal callback,
 	# or some other function from the running scene.
 	# Deleting the current scene at this point might be
@@ -13,21 +13,20 @@ func goto_scene(path):
 
 	# The way around this is deferring the load to a later time, when
 	# it is ensured that no code from the current scene is running:
-	call_deferred("_deferred_goto_scene", path)
+	_deferred_goto_scene.call_deferred(path)
 
 
-func _deferred_goto_scene(path):
-	# Immediately free the current scene, there is no risk here.
-	get_tree().get_current_scene().free()
+func _deferred_goto_scene(path: String):
+	# Immediately free the current scene. There is no risk here because the
+	# call to this method is already deferred.
+	get_tree().current_scene.free()
 
-	# Load new scene
-	var packed_scene = ResourceLoader.load(path)
+	var packed_scene := ResourceLoader.load(path) as PackedScene
 
-	# Instance the new scene
-	var instanced_scene = packed_scene.instantiate()
+	var instanced_scene := packed_scene.instantiate()
 
 	# Add it to the scene tree, as direct child of root
-	get_tree().get_root().add_child(instanced_scene)
+	get_tree().root.add_child(instanced_scene)
 
 	# Set it as the current scene, only after it has been added to the tree
-	get_tree().set_current_scene(instanced_scene)
+	get_tree().current_scene = instanced_scene

+ 4 - 8
loading/autoload/project.godot

@@ -14,20 +14,16 @@ config/name="Autoload (Singletons)"
 config/description="This demo shows how to use autoloads to change between scenes."
 run/main_scene="res://scene_a.tscn"
 config/features=PackedStringArray("4.0")
+run/low_processor_mode=true
 
 [autoload]
 
-global="res://global.gd"
+global="*res://global.gd"
 
 [display]
 
-window/stretch/mode="canvas_items"
-window/stretch/aspect="expand"
-
-[gdnative]
-
-singletons=[]
+window/vsync/vsync_mode=0
 
 [rendering]
 
-vulkan/rendering/back_end=1
+renderer/rendering_method="mobile"

+ 2 - 1
loading/autoload/scene_a.gd

@@ -1,4 +1,5 @@
 extends Panel
 
+
 func _on_goto_scene_pressed():
-	get_node(^"/root/global").goto_scene("res://scene_b.tscn")
+	global.goto_scene("res://scene_b.tscn")

+ 7 - 2
loading/autoload/scene_a.tscn

@@ -1,15 +1,19 @@
-[gd_scene load_steps=2 format=3 uid="uid://bh2ylkcsgejgy"]
+[gd_scene load_steps=2 format=3 uid="uid://6xgdg1bmya7c"]
 
 [ext_resource type="Script" path="res://scene_a.gd" id="1"]
 
 [node name="SceneA" type="Panel"]
+anchors_preset = 15
 anchor_right = 1.0
 anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
 size_flags_horizontal = 2
 size_flags_vertical = 2
-script = ExtResource( "1" )
+script = ExtResource("1")
 
 [node name="Label" type="Label" parent="."]
+layout_mode = 0
 offset_left = 64.0
 offset_top = 48.0
 offset_right = 104.0
@@ -18,6 +22,7 @@ size_flags_vertical = 0
 text = "This is scene A."
 
 [node name="GoToSceneB" type="Button" parent="."]
+layout_mode = 0
 offset_left = 64.0
 offset_top = 128.0
 offset_right = 192.0

+ 2 - 1
loading/autoload/scene_b.gd

@@ -1,4 +1,5 @@
 extends Panel
 
+
 func _on_goto_scene_pressed():
-	get_node(^"/root/global").goto_scene("res://scene_a.tscn")
+	global.goto_scene("res://scene_a.tscn")

+ 7 - 5
loading/autoload/scene_b.tscn

@@ -1,18 +1,19 @@
-[gd_scene load_steps=2 format=3 uid="uid://pt77vxjf3uwe"]
+[gd_scene load_steps=2 format=3 uid="uid://cmu1caqo7k7wy"]
 
 [ext_resource type="Script" path="res://scene_b.gd" id="1"]
 
 [node name="SceneB" type="Panel"]
+anchors_preset = 15
 anchor_right = 1.0
 anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
 size_flags_horizontal = 2
 size_flags_vertical = 2
-script = ExtResource( "1" )
-__meta__ = {
-"_edit_use_anchors_": false
-}
+script = ExtResource("1")
 
 [node name="Label" type="Label" parent="."]
+layout_mode = 0
 offset_left = 64.0
 offset_top = 48.0
 offset_right = 164.0
@@ -21,6 +22,7 @@ size_flags_vertical = 0
 text = "This is scene B."
 
 [node name="GoToSceneA" type="Button" parent="."]
+layout_mode = 0
 offset_left = 64.0
 offset_top = 128.0
 offset_right = 192.0

二進制
loading/autoload/screenshots/autoload.png


+ 0 - 15
loading/background_load/README.md

@@ -1,15 +0,0 @@
-# Background Load
-
-This is a demo showing how to use the `load_interactive()` method of
-[`ResourceLoader`](https://docs.godotengine.org/en/latest/classes/class_resourceloader.html)
-to load large scenes in the background with a progress bar.
-
-Language: GDScript
-
-Renderer: GLES 2
-
-Check out this demo on the asset library: https://godotengine.org/asset-library/asset/530
-
-## Screenshots
-
-![Screenshot](screenshots/paintings.png)

+ 0 - 64
loading/background_load/background_load.gd

@@ -1,64 +0,0 @@
-extends Control
-
-const SIMULATED_DELAY_SEC = 0.1
-
-var thread = null
-
-@onready var progress = $Progress
-
-func _thread_load(path):
-	var ril = ResourceLoader.load_interactive(path)
-	assert(ril)
-	var total = ril.get_stage_count()
-	# Call deferred to configure max load steps.
-	progress.call_deferred("set_max", total)
-
-	var res = null
-
-	while true: #iterate until we have a resource
-		# Update progress bar, use call deferred, which routes to main thread.
-		progress.call_deferred("set_value", ril.get_stage())
-		# Simulate a delay.
-		OS.delay_msec(int(SIMULATED_DELAY_SEC * 1000.0))
-		# Poll (does a load step).
-		var err = ril.poll()
-		# If OK, then load another one. If EOF, it' s done. Otherwise there was an error.
-		if err == ERR_FILE_EOF:
-			# Loading done, fetch resource.
-			res = ril.get_resource()
-			break
-		elif err != OK:
-			# Not OK, there was an error.
-			print("There was an error loading")
-			break
-
-	# Send whathever we did (or did not) get.
-	call_deferred("_thread_done", res)
-
-
-func _thread_done(resource):
-	assert(resource)
-
-	# Always wait for threads to finish, this is required on Windows.
-	thread.wait_to_finish()
-
-	# Hide the progress bar.
-	progress.hide()
-
-	# Instantiate new scene.
-	var new_scene = resource.instantiate()
-	# Free current scene.
-	get_tree().current_scene.free()
-	get_tree().current_scene = null
-	# Add new one to root.
-	get_tree().root.add_child(new_scene)
-	# Set as current scene.
-	get_tree().current_scene = new_scene
-
-	progress.visible = false
-
-func load_scene(path):
-	thread = Thread.new()
-	thread.start( self, "_thread_load", path)
-	raise() # Show on top.
-	progress.visible = true

+ 0 - 17
loading/background_load/background_load.tscn

@@ -1,17 +0,0 @@
-[gd_scene load_steps=2 format=2]
-
-[ext_resource path="res://background_load.gd" type="Script" id=1]
-
-[node name="BackgroundLoad" type="Control"]
-script = ExtResource( 1 )
-__meta__ = {
-"_edit_use_anchors_": false
-}
-
-[node name="Progress" type="ProgressBar" parent="."]
-visible = false
-offset_left = 7.0
-offset_top = 8.0
-offset_right = 207.0
-offset_bottom = 22.0
-step = 1.0

+ 0 - 5
loading/background_load/paintings.gd

@@ -1,5 +0,0 @@
-extends Node2D
-
-func _on_switch_pressed():
-	$CanvasLayer/Switch.hide()
-	background_load.load_scene("res://sculptures.tscn")

+ 0 - 213
loading/background_load/paintings.tscn

@@ -1,213 +0,0 @@
-[gd_scene load_steps=9 format=2]
-
-[ext_resource path="res://paintings.gd" type="Script" id=1]
-[ext_resource path="res://paintings/painting_babel.jpg" type="Texture2D" id=2]
-[ext_resource path="res://paintings/painting_las_meninas.png" type="Texture2D" id=3]
-[ext_resource path="res://paintings/painting_mona_lisa.jpg" type="Texture2D" id=4]
-[ext_resource path="res://paintings/painting_old_guitarist.jpg" type="Texture2D" id=5]
-[ext_resource path="res://paintings/painting_parasol.jpg" type="Texture2D" id=6]
-[ext_resource path="res://paintings/painting_the_swing.jpg" type="Texture2D" id=7]
-
-[sub_resource type="Animation" id=1]
-resource_name = "move_around"
-length = 4.0
-loop = true
-tracks/0/type = "value"
-tracks/0/path = NodePath("MonaLisa:position")
-tracks/0/interp = 2
-tracks/0/loop_wrap = true
-tracks/0/imported = false
-tracks/0/enabled = true
-tracks/0/keys = {
-"times": PackedFloat32Array(0, 2),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [Vector2(117.659, 173.793), Vector2(164.387, 206.955)]
-}
-tracks/1/type = "value"
-tracks/1/path = NodePath("MonaLisa:rotation_degrees")
-tracks/1/interp = 2
-tracks/1/loop_wrap = true
-tracks/1/imported = false
-tracks/1/enabled = true
-tracks/1/keys = {
-"times": PackedFloat32Array(0, 2),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [0.0, 0.0]
-}
-tracks/2/type = "value"
-tracks/2/path = NodePath("Parasol:position")
-tracks/2/interp = 2
-tracks/2/loop_wrap = true
-tracks/2/imported = false
-tracks/2/enabled = true
-tracks/2/keys = {
-"times": PackedFloat32Array(0, 2),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [Vector2(451.448, 256.916), Vector2(483.102, 317.21)]
-}
-tracks/3/type = "value"
-tracks/3/path = NodePath("Parasol:rotation_degrees")
-tracks/3/interp = 2
-tracks/3/loop_wrap = true
-tracks/3/imported = false
-tracks/3/enabled = true
-tracks/3/keys = {
-"times": PackedFloat32Array(0, 2),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [0.0, 0.0]
-}
-tracks/4/type = "value"
-tracks/4/path = NodePath("TheSwing:position")
-tracks/4/interp = 2
-tracks/4/loop_wrap = true
-tracks/4/imported = false
-tracks/4/enabled = true
-tracks/4/keys = {
-"times": PackedFloat32Array(0, 2),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [Vector2(715.927, 181.745), Vector2(661.663, 205.863)]
-}
-tracks/5/type = "value"
-tracks/5/path = NodePath("TheSwing:rotation_degrees")
-tracks/5/interp = 2
-tracks/5/loop_wrap = true
-tracks/5/imported = false
-tracks/5/enabled = true
-tracks/5/keys = {
-"times": PackedFloat32Array(0, 2),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [0.0, 0.0]
-}
-tracks/6/type = "value"
-tracks/6/path = NodePath("OldGuitarist:position")
-tracks/6/interp = 2
-tracks/6/loop_wrap = true
-tracks/6/imported = false
-tracks/6/enabled = true
-tracks/6/keys = {
-"times": PackedFloat32Array(0, 2),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [Vector2(886.982, 185.641), Vector2(901.179, 210.693)]
-}
-tracks/7/type = "value"
-tracks/7/path = NodePath("OldGuitarist:rotation_degrees")
-tracks/7/interp = 2
-tracks/7/loop_wrap = true
-tracks/7/imported = false
-tracks/7/enabled = true
-tracks/7/keys = {
-"times": PackedFloat32Array(0, 2),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [0.0, 15.0]
-}
-tracks/8/type = "value"
-tracks/8/path = NodePath("Babel:position")
-tracks/8/interp = 2
-tracks/8/loop_wrap = true
-tracks/8/imported = false
-tracks/8/enabled = true
-tracks/8/keys = {
-"times": PackedFloat32Array(0, 2),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [Vector2(155.796, 468.287), Vector2(194.21, 444.904)]
-}
-tracks/9/type = "value"
-tracks/9/path = NodePath("Babel:rotation_degrees")
-tracks/9/interp = 2
-tracks/9/loop_wrap = true
-tracks/9/imported = false
-tracks/9/enabled = true
-tracks/9/keys = {
-"times": PackedFloat32Array(0, 2),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [0.0, 0.0]
-}
-tracks/10/type = "value"
-tracks/10/path = NodePath("LasMeninas:position")
-tracks/10/interp = 2
-tracks/10/loop_wrap = true
-tracks/10/imported = false
-tracks/10/enabled = true
-tracks/10/keys = {
-"times": PackedFloat32Array(0, 2),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [Vector2(861.734, 494.059), Vector2(840.022, 470.677)]
-}
-tracks/11/type = "value"
-tracks/11/path = NodePath("LasMeninas:rotation_degrees")
-tracks/11/interp = 2
-tracks/11/loop_wrap = true
-tracks/11/imported = false
-tracks/11/enabled = true
-tracks/11/keys = {
-"times": PackedFloat32Array(0, 2),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [0.0, 0.0]
-}
-
-[node name="Paintings" type="Node2D"]
-script = ExtResource( 1 )
-
-[node name="Babel" type="Sprite2D" parent="."]
-position = Vector2(155.796, 468.287)
-scale = Vector2(0.29005, 0.29005)
-texture = ExtResource( 2 )
-
-[node name="LasMeninas" type="Sprite2D" parent="."]
-position = Vector2(861.734, 494.059)
-scale = Vector2(0.348146, 0.348146)
-texture = ExtResource( 3 )
-
-[node name="MonaLisa" type="Sprite2D" parent="."]
-position = Vector2(117.659, 173.793)
-scale = Vector2(0.696799, 0.696799)
-texture = ExtResource( 4 )
-
-[node name="OldGuitarist" type="Sprite2D" parent="."]
-position = Vector2(886.982, 185.641)
-scale = Vector2(0.344706, 0.328421)
-texture = ExtResource( 5 )
-
-[node name="Parasol" type="Sprite2D" parent="."]
-position = Vector2(451.448, 256.916)
-scale = Vector2(0.557998, 0.557998)
-texture = ExtResource( 6 )
-
-[node name="TheSwing" type="Sprite2D" parent="."]
-position = Vector2(715.927, 181.745)
-scale = Vector2(0.286677, 0.286677)
-texture = ExtResource( 7 )
-
-[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
-autoplay = "move_around"
-anims/move_around = SubResource( 1 )
-
-[node name="Camera2D" type="Camera2D" parent="."]
-offset = Vector2(512, 300)
-current = true
-
-[node name="CanvasLayer" type="CanvasLayer" parent="."]
-
-[node name="Switch" type="Button" parent="CanvasLayer"]
-offset_left = 10.0
-offset_top = 10.0
-offset_right = 156.0
-offset_bottom = 30.0
-text = "Switch to Sculptures"
-__meta__ = {
-"_edit_use_anchors_": false
-}
-
-[connection signal="pressed" from="CanvasLayer/Switch" to="." method="_on_switch_pressed"]

+ 0 - 109
loading/background_load/project.godot

@@ -1,109 +0,0 @@
-; Engine configuration file.
-; It's best edited using the editor UI and not directly,
-; since the parameters that go here are not all obvious.
-;
-; Format:
-;   [section] ; section goes between []
-;   param=value ; assign values to parameters
-
-config_version=4
-
-[application]
-
-config/name="Background Thread Loading Demo"
-config/description="This is a demo showing how to use the load_interactive() method of
-ResourceLoader to load large scenes in the background with a progress bar."
-run/main_scene="res://paintings.tscn"
-
-[autoload]
-
-background_load="*res://background_load.tscn"
-
-[display]
-
-window/dpi/allow_hidpi=true
-window/stretch/mode="2d"
-window/stretch/aspect="expand"
-
-[input]
-
-ui_accept={
-"deadzone": 0.5,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777221,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
-, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777222,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
-, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
-, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
-]
-}
-ui_select={
-"deadzone": 0.5,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
-, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":3,"pressure":0.0,"pressed":false,"script":null)
-]
-}
-ui_cancel={
-"deadzone": 0.5,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777217,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
-, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
-]
-}
-ui_focus_next={
-"deadzone": 0.5,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777218,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
-]
-}
-ui_focus_prev={
-"deadzone": 0.5,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":true,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777218,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
-]
-}
-ui_left={
-"deadzone": 0.5,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777231,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
-, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
-]
-}
-ui_right={
-"deadzone": 0.5,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777233,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
-, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
-]
-}
-ui_up={
-"deadzone": 0.5,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777232,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
-, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
-]
-}
-ui_down={
-"deadzone": 0.5,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777234,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
-, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
-]
-}
-ui_page_up={
-"deadzone": 0.5,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777235,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
-]
-}
-ui_page_down={
-"deadzone": 0.5,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777236,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
-]
-}
-ui_home={
-"deadzone": 0.5,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777229,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
-]
-}
-ui_end={
-"deadzone": 0.5,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777230,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
-]
-}
-
-[rendering]
-
-quality/driver/driver_name="GLES2"
-vram_compression/import_etc=true
-vram_compression/import_etc2=false

二進制
loading/background_load/screenshots/paintings.png


+ 0 - 5
loading/background_load/sculptures.gd

@@ -1,5 +0,0 @@
-extends Node2D
-
-func _on_switch_pressed():
-	$CanvasLayer/Switch.hide()
-	background_load.load_scene("res://paintings.tscn")

+ 0 - 141
loading/background_load/sculptures.tscn

@@ -1,141 +0,0 @@
-[gd_scene load_steps=9 format=2]
-
-[ext_resource path="res://sculptures.gd" type="Script" id=1]
-[ext_resource path="res://sculptures/sculpture_david.jpg" type="Texture2D" id=2]
-[ext_resource path="res://sculptures/sculpture_fountain.jpg" type="Texture2D" id=3]
-[ext_resource path="res://sculptures/sculpture_four_parts_of_earth.jpg" type="Texture2D" id=4]
-[ext_resource path="res://sculptures/sculpture_lincoln.jpg" type="Texture2D" id=5]
-[ext_resource path="res://sculptures/sculpture_thinker.jpg" type="Texture2D" id=6]
-[ext_resource path="res://sculptures/sculpture_venus.png" type="Texture2D" id=7]
-
-[sub_resource type="Animation" id=1]
-resource_name = "colorcycle"
-length = 8.0
-loop = true
-tracks/0/type = "value"
-tracks/0/path = NodePath("FourPartsOfEarth:modulate")
-tracks/0/interp = 1
-tracks/0/loop_wrap = true
-tracks/0/imported = false
-tracks/0/enabled = true
-tracks/0/keys = {
-"times": PackedFloat32Array(0, 4),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [Color(1, 1, 1, 1), Color(0.827451, 0.25098, 0.25098, 1)]
-}
-tracks/1/type = "value"
-tracks/1/path = NodePath("Fountain:modulate")
-tracks/1/interp = 1
-tracks/1/loop_wrap = true
-tracks/1/imported = false
-tracks/1/enabled = true
-tracks/1/keys = {
-"times": PackedFloat32Array(0, 4),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
-}
-tracks/2/type = "value"
-tracks/2/path = NodePath("Lincoln:modulate")
-tracks/2/interp = 1
-tracks/2/loop_wrap = true
-tracks/2/imported = false
-tracks/2/enabled = true
-tracks/2/keys = {
-"times": PackedFloat32Array(0, 4.1),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [Color(1, 1, 1, 1), Color(0.32549, 0.407843, 0.862745, 1)]
-}
-tracks/3/type = "value"
-tracks/3/path = NodePath("David:modulate")
-tracks/3/interp = 1
-tracks/3/loop_wrap = true
-tracks/3/imported = false
-tracks/3/enabled = true
-tracks/3/keys = {
-"times": PackedFloat32Array(0, 4.1),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [Color(1, 1, 1, 1), Color(0.180392, 0.866667, 0.137255, 1)]
-}
-tracks/4/type = "value"
-tracks/4/path = NodePath("Thinker:modulate")
-tracks/4/interp = 1
-tracks/4/loop_wrap = true
-tracks/4/imported = false
-tracks/4/enabled = true
-tracks/4/keys = {
-"times": PackedFloat32Array(0, 4.1),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [Color(1, 1, 1, 1), Color(0.898039, 0, 1, 1)]
-}
-tracks/5/type = "value"
-tracks/5/path = NodePath("Venus:modulate")
-tracks/5/interp = 1
-tracks/5/loop_wrap = true
-tracks/5/imported = false
-tracks/5/enabled = true
-tracks/5/keys = {
-"times": PackedFloat32Array(0, 4.1),
-"transitions": PackedFloat32Array(1, 1),
-"update": 0,
-"values": [Color(1, 1, 1, 1), Color(0, 0, 0, 1)]
-}
-
-[node name="Sculptures" type="Node2D"]
-script = ExtResource( 1 )
-
-[node name="David" type="Sprite2D" parent="."]
-position = Vector2(567.784, 196.577)
-scale = Vector2(0.447348, 0.447348)
-texture = ExtResource( 2 )
-
-[node name="Fountain" type="Sprite2D" parent="."]
-position = Vector2(152.971, 513.499)
-scale = Vector2(0.191615, 0.191615)
-texture = ExtResource( 3 )
-
-[node name="FourPartsOfEarth" type="Sprite2D" parent="."]
-position = Vector2(480.743, 588.027)
-scale = Vector2(0.198693, 0.198693)
-texture = ExtResource( 4 )
-
-[node name="Lincoln" type="Sprite2D" parent="."]
-position = Vector2(211.852, 203.688)
-scale = Vector2(0.386179, 0.378971)
-texture = ExtResource( 5 )
-
-[node name="Thinker" type="Sprite2D" parent="."]
-position = Vector2(854.336, 202.363)
-scale = Vector2(0.182302, 0.182302)
-texture = ExtResource( 6 )
-
-[node name="Venus" type="Sprite2D" parent="."]
-position = Vector2(848.731, 495.153)
-scale = Vector2(0.402249, 0.402249)
-texture = ExtResource( 7 )
-
-[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
-autoplay = "colorcycle"
-anims/colorcycle = SubResource( 1 )
-
-[node name="Camera2D" type="Camera2D" parent="."]
-offset = Vector2(512, 300)
-current = true
-
-[node name="CanvasLayer" type="CanvasLayer" parent="."]
-
-[node name="Switch" type="Button" parent="CanvasLayer"]
-offset_left = 10.0
-offset_top = 10.0
-offset_right = 142.0
-offset_bottom = 30.0
-text = "Switch to Paintings"
-__meta__ = {
-"_edit_use_anchors_": false
-}
-
-[connection signal="pressed" from="CanvasLayer/Switch" to="." method="_on_switch_pressed"]

二進制
loading/background_load/sculptures/sculpture_david.jpg


+ 0 - 35
loading/background_load/sculptures/sculpture_david.jpg.import

@@ -1,35 +0,0 @@
-[remap]
-
-importer="texture"
-type="StreamTexture2D"
-path="res://.godot/imported/sculpture_david.jpg-a970dbaef2d14bf5b95bd6bc742cc5b7.stex"
-metadata={
-"vram_texture": false
-}
-
-[deps]
-
-source_file="res://sculptures/sculpture_david.jpg"
-dest_files=["res://.godot/imported/sculpture_david.jpg-a970dbaef2d14bf5b95bd6bc742cc5b7.stex"]
-
-[params]
-
-compress/mode=0
-compress/lossy_quality=0.7
-compress/hdr_mode=0
-compress/bptc_ldr=0
-compress/normal_map=0
-flags/repeat=0
-flags/filter=true
-flags/mipmaps=true
-flags/anisotropic=false
-flags/srgb=2
-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

二進制
loading/background_load/sculptures/sculpture_fountain.jpg


+ 0 - 35
loading/background_load/sculptures/sculpture_fountain.jpg.import

@@ -1,35 +0,0 @@
-[remap]
-
-importer="texture"
-type="StreamTexture2D"
-path="res://.godot/imported/sculpture_fountain.jpg-c97f66cd28cbdedd878a6bccaee9f8ab.stex"
-metadata={
-"vram_texture": false
-}
-
-[deps]
-
-source_file="res://sculptures/sculpture_fountain.jpg"
-dest_files=["res://.godot/imported/sculpture_fountain.jpg-c97f66cd28cbdedd878a6bccaee9f8ab.stex"]
-
-[params]
-
-compress/mode=0
-compress/lossy_quality=0.7
-compress/hdr_mode=0
-compress/bptc_ldr=0
-compress/normal_map=0
-flags/repeat=0
-flags/filter=true
-flags/mipmaps=true
-flags/anisotropic=false
-flags/srgb=2
-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

二進制
loading/background_load/sculptures/sculpture_four_parts_of_earth.jpg


+ 0 - 35
loading/background_load/sculptures/sculpture_four_parts_of_earth.jpg.import

@@ -1,35 +0,0 @@
-[remap]
-
-importer="texture"
-type="StreamTexture2D"
-path="res://.godot/imported/sculpture_four_parts_of_earth.jpg-3a91357b6e4b11dc5c9d6cf4e883ae09.stex"
-metadata={
-"vram_texture": false
-}
-
-[deps]
-
-source_file="res://sculptures/sculpture_four_parts_of_earth.jpg"
-dest_files=["res://.godot/imported/sculpture_four_parts_of_earth.jpg-3a91357b6e4b11dc5c9d6cf4e883ae09.stex"]
-
-[params]
-
-compress/mode=0
-compress/lossy_quality=0.7
-compress/hdr_mode=0
-compress/bptc_ldr=0
-compress/normal_map=0
-flags/repeat=0
-flags/filter=true
-flags/mipmaps=true
-flags/anisotropic=false
-flags/srgb=2
-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

二進制
loading/background_load/sculptures/sculpture_lincoln.jpg


+ 0 - 35
loading/background_load/sculptures/sculpture_lincoln.jpg.import

@@ -1,35 +0,0 @@
-[remap]
-
-importer="texture"
-type="StreamTexture2D"
-path="res://.godot/imported/sculpture_lincoln.jpg-6788997c8779fe1e17e7199d4f455ddd.stex"
-metadata={
-"vram_texture": false
-}
-
-[deps]
-
-source_file="res://sculptures/sculpture_lincoln.jpg"
-dest_files=["res://.godot/imported/sculpture_lincoln.jpg-6788997c8779fe1e17e7199d4f455ddd.stex"]
-
-[params]
-
-compress/mode=0
-compress/lossy_quality=0.7
-compress/hdr_mode=0
-compress/bptc_ldr=0
-compress/normal_map=0
-flags/repeat=0
-flags/filter=true
-flags/mipmaps=true
-flags/anisotropic=false
-flags/srgb=2
-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

二進制
loading/background_load/sculptures/sculpture_thinker.jpg


+ 0 - 35
loading/background_load/sculptures/sculpture_thinker.jpg.import

@@ -1,35 +0,0 @@
-[remap]
-
-importer="texture"
-type="StreamTexture2D"
-path="res://.godot/imported/sculpture_thinker.jpg-09c1107239db80502d91eb2eed125d58.stex"
-metadata={
-"vram_texture": false
-}
-
-[deps]
-
-source_file="res://sculptures/sculpture_thinker.jpg"
-dest_files=["res://.godot/imported/sculpture_thinker.jpg-09c1107239db80502d91eb2eed125d58.stex"]
-
-[params]
-
-compress/mode=0
-compress/lossy_quality=0.7
-compress/hdr_mode=0
-compress/bptc_ldr=0
-compress/normal_map=0
-flags/repeat=0
-flags/filter=true
-flags/mipmaps=true
-flags/anisotropic=false
-flags/srgb=2
-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

二進制
loading/background_load/sculptures/sculpture_venus.png


+ 0 - 35
loading/background_load/sculptures/sculpture_venus.png.import

@@ -1,35 +0,0 @@
-[remap]
-
-importer="texture"
-type="StreamTexture2D"
-path="res://.godot/imported/sculpture_venus.png-f25859b819e865591053766b700269eb.stex"
-metadata={
-"vram_texture": false
-}
-
-[deps]
-
-source_file="res://sculptures/sculpture_venus.png"
-dest_files=["res://.godot/imported/sculpture_venus.png-f25859b819e865591053766b700269eb.stex"]
-
-[params]
-
-compress/mode=0
-compress/lossy_quality=0.7
-compress/hdr_mode=0
-compress/bptc_ldr=0
-compress/normal_map=0
-flags/repeat=0
-flags/filter=true
-flags/mipmaps=true
-flags/anisotropic=false
-flags/srgb=2
-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

+ 13 - 0
loading/load_threaded/README.md

@@ -0,0 +1,13 @@
+# Threaded Loading
+
+This demo demonstrates how to use ResourceLoader for background loading.
+
+Language: GDScript
+
+Renderer: Mobile
+
+Check out this demo on the asset library: *Coming soon*
+
+## Screenshots
+
+![Screenshot](screenshots/paintings.png)

二進制
loading/load_threaded/icon.png


+ 14 - 15
loading/multiple_threads_loading/icon.png.import → loading/load_threaded/icon.png.import

@@ -1,8 +1,9 @@
 [remap]
 
 importer="texture"
-type="StreamTexture2D"
-path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
+type="CompressedTexture2D"
+uid="uid://y4rcaycsgn4r"
+path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
 metadata={
 "vram_texture": false
 }
@@ -10,26 +11,24 @@ metadata={
 [deps]
 
 source_file="res://icon.png"
-dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
+dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
 
 [params]
 
 compress/mode=0
 compress/lossy_quality=0.7
-compress/hdr_mode=0
+compress/hdr_compression=1
 compress/bptc_ldr=0
 compress/normal_map=0
-flags/repeat=0
-flags/filter=true
-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

+ 42 - 0
loading/load_threaded/load_threaded.gd

@@ -0,0 +1,42 @@
+extends VBoxContainer
+
+
+func _on_start_loading_pressed():
+	ResourceLoader.load_threaded_request("res://paintings/painting_babel.jpg")
+	ResourceLoader.load_threaded_request("res://paintings/painting_las_meninas.png")
+	ResourceLoader.load_threaded_request("res://paintings/painting_mona_lisa.jpg")
+	ResourceLoader.load_threaded_request("res://paintings/painting_old_guitarist.jpg")
+	ResourceLoader.load_threaded_request("res://paintings/painting_parasol.jpg")
+	ResourceLoader.load_threaded_request("res://paintings/painting_the_swing.jpg")
+	for current_button in $GetLoaded.get_children():
+		current_button.disabled = false
+
+
+func _on_babel_pressed():
+	$Paintings/Babel.texture = ResourceLoader.load_threaded_get("res://paintings/painting_babel.jpg")
+	$GetLoaded/Babel.disabled = true
+
+
+func _on_las_meninas_pressed():
+	$Paintings/LasMeninas.texture = ResourceLoader.load_threaded_get("res://paintings/painting_las_meninas.png")
+	$GetLoaded/LasMeninas.disabled = true
+
+
+func _on_mona_lisa_pressed():
+	$Paintings/MonaLisa.texture = ResourceLoader.load_threaded_get("res://paintings/painting_mona_lisa.jpg")
+	$GetLoaded/MonaLisa.disabled = true
+
+
+func _on_old_guitarist_pressed():
+	$Paintings/OldGuitarist.texture = ResourceLoader.load_threaded_get("res://paintings/painting_old_guitarist.jpg")
+	$GetLoaded/OldGuitarist.disabled = true
+
+
+func _on_parasol_pressed():
+	$Paintings/Parasol.texture = ResourceLoader.load_threaded_get("res://paintings/painting_parasol.jpg")
+	$GetLoaded/Parasol.disabled = true
+
+
+func _on_swing_pressed():
+	$Paintings/Swing.texture = ResourceLoader.load_threaded_get("res://paintings/painting_the_swing.jpg")
+	$GetLoaded/Swing.disabled = true

+ 102 - 0
loading/load_threaded/load_threaded.tscn

@@ -0,0 +1,102 @@
+[gd_scene load_steps=2 format=3 uid="uid://gc6pbdkdi7xt"]
+
+[ext_resource type="Script" path="res://load_threaded.gd" id="1_5o27a"]
+
+[node name="LoadThreaded" type="VBoxContainer"]
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+script = ExtResource("1_5o27a")
+
+[node name="Paintings" type="HBoxContainer" parent="."]
+layout_mode = 2
+size_flags_vertical = 3
+
+[node name="Babel" type="TextureRect" parent="Paintings"]
+layout_mode = 2
+size_flags_horizontal = 3
+ignore_texture_size = true
+stretch_mode = 5
+
+[node name="LasMeninas" type="TextureRect" parent="Paintings"]
+layout_mode = 2
+size_flags_horizontal = 3
+ignore_texture_size = true
+stretch_mode = 5
+
+[node name="MonaLisa" type="TextureRect" parent="Paintings"]
+layout_mode = 2
+size_flags_horizontal = 3
+ignore_texture_size = true
+stretch_mode = 5
+
+[node name="OldGuitarist" type="TextureRect" parent="Paintings"]
+layout_mode = 2
+size_flags_horizontal = 3
+ignore_texture_size = true
+stretch_mode = 5
+
+[node name="Parasol" type="TextureRect" parent="Paintings"]
+layout_mode = 2
+size_flags_horizontal = 3
+ignore_texture_size = true
+stretch_mode = 5
+
+[node name="Swing" type="TextureRect" parent="Paintings"]
+layout_mode = 2
+size_flags_horizontal = 3
+ignore_texture_size = true
+stretch_mode = 5
+
+[node name="StartLoading" type="Button" parent="."]
+layout_mode = 2
+text = "Start Loading"
+
+[node name="GetLoaded" type="HBoxContainer" parent="."]
+layout_mode = 2
+
+[node name="Babel" type="Button" parent="GetLoaded"]
+layout_mode = 2
+size_flags_horizontal = 3
+disabled = true
+text = "The Tower of Babel"
+
+[node name="LasMeninas" type="Button" parent="GetLoaded"]
+layout_mode = 2
+size_flags_horizontal = 3
+disabled = true
+text = "Las Meninas"
+
+[node name="MonaLisa" type="Button" parent="GetLoaded"]
+layout_mode = 2
+size_flags_horizontal = 3
+disabled = true
+text = "Mona Lisa"
+
+[node name="OldGuitarist" type="Button" parent="GetLoaded"]
+layout_mode = 2
+size_flags_horizontal = 3
+disabled = true
+text = "The Old Guitarist"
+
+[node name="Parasol" type="Button" parent="GetLoaded"]
+layout_mode = 2
+size_flags_horizontal = 3
+disabled = true
+text = "Woman with a Parasol – Madame Monet and Her Son"
+
+[node name="Swing" type="Button" parent="GetLoaded"]
+layout_mode = 2
+size_flags_horizontal = 3
+disabled = true
+text = "The Swing"
+
+[connection signal="pressed" from="StartLoading" to="." method="_on_start_loading_pressed"]
+[connection signal="pressed" from="GetLoaded/Babel" to="." method="_on_babel_pressed"]
+[connection signal="pressed" from="GetLoaded/LasMeninas" to="." method="_on_las_meninas_pressed"]
+[connection signal="pressed" from="GetLoaded/MonaLisa" to="." method="_on_mona_lisa_pressed"]
+[connection signal="pressed" from="GetLoaded/OldGuitarist" to="." method="_on_old_guitarist_pressed"]
+[connection signal="pressed" from="GetLoaded/Parasol" to="." method="_on_parasol_pressed"]
+[connection signal="pressed" from="GetLoaded/Swing" to="." method="_on_swing_pressed"]

+ 0 - 0
loading/background_load/paintings/painting_babel.jpg → loading/load_threaded/paintings/painting_babel.jpg


+ 14 - 15
loading/background_load/paintings/painting_babel.jpg.import → loading/load_threaded/paintings/painting_babel.jpg.import

@@ -1,8 +1,9 @@
 [remap]
 
 importer="texture"
-type="StreamTexture2D"
-path="res://.godot/imported/painting_babel.jpg-7d4afda4b0268025e231a7f9e793a18d.stex"
+type="CompressedTexture2D"
+uid="uid://y5tmlxhhiv2u"
+path="res://.godot/imported/painting_babel.jpg-7d4afda4b0268025e231a7f9e793a18d.ctex"
 metadata={
 "vram_texture": false
 }
@@ -10,26 +11,24 @@ metadata={
 [deps]
 
 source_file="res://paintings/painting_babel.jpg"
-dest_files=["res://.godot/imported/painting_babel.jpg-7d4afda4b0268025e231a7f9e793a18d.stex"]
+dest_files=["res://.godot/imported/painting_babel.jpg-7d4afda4b0268025e231a7f9e793a18d.ctex"]
 
 [params]
 
 compress/mode=0
 compress/lossy_quality=0.7
-compress/hdr_mode=0
+compress/hdr_compression=1
 compress/bptc_ldr=0
 compress/normal_map=0
-flags/repeat=0
-flags/filter=true
-flags/mipmaps=true
-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/background_load/paintings/painting_las_meninas.png → loading/load_threaded/paintings/painting_las_meninas.png


+ 14 - 15
loading/background_load/paintings/painting_las_meninas.png.import → loading/load_threaded/paintings/painting_las_meninas.png.import

@@ -1,8 +1,9 @@
 [remap]
 
 importer="texture"
-type="StreamTexture2D"
-path="res://.godot/imported/painting_las_meninas.png-980a9e4669b648b01417bfb871e282ee.stex"
+type="CompressedTexture2D"
+uid="uid://d1pbl328jrf0k"
+path="res://.godot/imported/painting_las_meninas.png-980a9e4669b648b01417bfb871e282ee.ctex"
 metadata={
 "vram_texture": false
 }
@@ -10,26 +11,24 @@ metadata={
 [deps]
 
 source_file="res://paintings/painting_las_meninas.png"
-dest_files=["res://.godot/imported/painting_las_meninas.png-980a9e4669b648b01417bfb871e282ee.stex"]
+dest_files=["res://.godot/imported/painting_las_meninas.png-980a9e4669b648b01417bfb871e282ee.ctex"]
 
 [params]
 
 compress/mode=0
 compress/lossy_quality=0.7
-compress/hdr_mode=0
+compress/hdr_compression=1
 compress/bptc_ldr=0
 compress/normal_map=0
-flags/repeat=0
-flags/filter=true
-flags/mipmaps=true
-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

+ 0 - 0
loading/background_load/paintings/painting_mona_lisa.jpg → loading/load_threaded/paintings/painting_mona_lisa.jpg


+ 14 - 15
loading/background_load/paintings/painting_mona_lisa.jpg.import → loading/load_threaded/paintings/painting_mona_lisa.jpg.import

@@ -1,8 +1,9 @@
 [remap]
 
 importer="texture"
-type="StreamTexture2D"
-path="res://.godot/imported/painting_mona_lisa.jpg-0d1e89a489f14142e264e1f238465e1c.stex"
+type="CompressedTexture2D"
+uid="uid://bad1drr2you5e"
+path="res://.godot/imported/painting_mona_lisa.jpg-0d1e89a489f14142e264e1f238465e1c.ctex"
 metadata={
 "vram_texture": false
 }
@@ -10,26 +11,24 @@ metadata={
 [deps]
 
 source_file="res://paintings/painting_mona_lisa.jpg"
-dest_files=["res://.godot/imported/painting_mona_lisa.jpg-0d1e89a489f14142e264e1f238465e1c.stex"]
+dest_files=["res://.godot/imported/painting_mona_lisa.jpg-0d1e89a489f14142e264e1f238465e1c.ctex"]
 
 [params]
 
 compress/mode=0
 compress/lossy_quality=0.7
-compress/hdr_mode=0
+compress/hdr_compression=1
 compress/bptc_ldr=0
 compress/normal_map=0
-flags/repeat=0
-flags/filter=true
-flags/mipmaps=true
-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

+ 0 - 0
loading/background_load/paintings/painting_old_guitarist.jpg → loading/load_threaded/paintings/painting_old_guitarist.jpg


+ 14 - 15
loading/background_load/paintings/painting_old_guitarist.jpg.import → loading/load_threaded/paintings/painting_old_guitarist.jpg.import

@@ -1,8 +1,9 @@
 [remap]
 
 importer="texture"
-type="StreamTexture2D"
-path="res://.godot/imported/painting_old_guitarist.jpg-9b4236f27fd614bf0a429568255ea118.stex"
+type="CompressedTexture2D"
+uid="uid://bn3aufteoq2sa"
+path="res://.godot/imported/painting_old_guitarist.jpg-9b4236f27fd614bf0a429568255ea118.ctex"
 metadata={
 "vram_texture": false
 }
@@ -10,26 +11,24 @@ metadata={
 [deps]
 
 source_file="res://paintings/painting_old_guitarist.jpg"
-dest_files=["res://.godot/imported/painting_old_guitarist.jpg-9b4236f27fd614bf0a429568255ea118.stex"]
+dest_files=["res://.godot/imported/painting_old_guitarist.jpg-9b4236f27fd614bf0a429568255ea118.ctex"]
 
 [params]
 
 compress/mode=0
 compress/lossy_quality=0.7
-compress/hdr_mode=0
+compress/hdr_compression=1
 compress/bptc_ldr=0
 compress/normal_map=0
-flags/repeat=0
-flags/filter=true
-flags/mipmaps=true
-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

+ 0 - 0
loading/background_load/paintings/painting_parasol.jpg → loading/load_threaded/paintings/painting_parasol.jpg


+ 14 - 15
loading/background_load/paintings/painting_parasol.jpg.import → loading/load_threaded/paintings/painting_parasol.jpg.import

@@ -1,8 +1,9 @@
 [remap]
 
 importer="texture"
-type="StreamTexture2D"
-path="res://.godot/imported/painting_parasol.jpg-58515a51999e7c2414ba8e02c335b3cf.stex"
+type="CompressedTexture2D"
+uid="uid://qut3pkm72hge"
+path="res://.godot/imported/painting_parasol.jpg-58515a51999e7c2414ba8e02c335b3cf.ctex"
 metadata={
 "vram_texture": false
 }
@@ -10,26 +11,24 @@ metadata={
 [deps]
 
 source_file="res://paintings/painting_parasol.jpg"
-dest_files=["res://.godot/imported/painting_parasol.jpg-58515a51999e7c2414ba8e02c335b3cf.stex"]
+dest_files=["res://.godot/imported/painting_parasol.jpg-58515a51999e7c2414ba8e02c335b3cf.ctex"]
 
 [params]
 
 compress/mode=0
 compress/lossy_quality=0.7
-compress/hdr_mode=0
+compress/hdr_compression=1
 compress/bptc_ldr=0
 compress/normal_map=0
-flags/repeat=0
-flags/filter=true
-flags/mipmaps=true
-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

+ 0 - 0
loading/background_load/paintings/painting_the_swing.jpg → loading/load_threaded/paintings/painting_the_swing.jpg


+ 14 - 15
loading/background_load/paintings/painting_the_swing.jpg.import → loading/load_threaded/paintings/painting_the_swing.jpg.import

@@ -1,8 +1,9 @@
 [remap]
 
 importer="texture"
-type="StreamTexture2D"
-path="res://.godot/imported/painting_the_swing.jpg-c81abef8954f7fb30f742b957576d4d2.stex"
+type="CompressedTexture2D"
+uid="uid://bqtsy0u0x7drj"
+path="res://.godot/imported/painting_the_swing.jpg-c81abef8954f7fb30f742b957576d4d2.ctex"
 metadata={
 "vram_texture": false
 }
@@ -10,26 +11,24 @@ metadata={
 [deps]
 
 source_file="res://paintings/painting_the_swing.jpg"
-dest_files=["res://.godot/imported/painting_the_swing.jpg-c81abef8954f7fb30f742b957576d4d2.stex"]
+dest_files=["res://.godot/imported/painting_the_swing.jpg-c81abef8954f7fb30f742b957576d4d2.ctex"]
 
 [params]
 
 compress/mode=0
 compress/lossy_quality=0.7
-compress/hdr_mode=0
+compress/hdr_compression=1
 compress/bptc_ldr=0
 compress/normal_map=0
-flags/repeat=0
-flags/filter=true
-flags/mipmaps=true
-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

+ 26 - 0
loading/load_threaded/project.godot

@@ -0,0 +1,26 @@
+; Engine configuration file.
+; It's best edited using the editor UI and not directly,
+; since the parameters that go here are not all obvious.
+;
+; Format:
+;   [section] ; section goes between []
+;   param=value ; assign values to parameters
+
+config_version=5
+
+[application]
+
+config/name="Threaded Loading"
+config/description="This demo demonstrates how to use ResourceLoader for background loading."
+run/main_scene="res://load_threaded.tscn"
+config/features=PackedStringArray("4.0")
+run/low_processor_mode=true
+config/icon="res://icon.png"
+
+[display]
+
+window/vsync/vsync_mode=0
+
+[rendering]
+
+renderer/rendering_method="mobile"

+ 0 - 0
loading/background_load/screenshots/.gdignore → loading/load_threaded/screenshots/.gdignore


二進制
loading/load_threaded/screenshots/paintings.png


+ 0 - 18
loading/multiple_threads_loading/README.md

@@ -1,18 +0,0 @@
-# Multiple-threads loading demo
-
-This demo shows how you can organize
-background loading using multiple threads.
-
-Language: GDScript
-
-Renderer: GLES 2
-
-Check out this demo on the asset library: https://godotengine.org/asset-library/asset/582
-
-## How does it work?
-
-[Official documentation - Using multiple threads](http://docs.godotengine.org/en/3.2/tutorials/io/background_loading.html#using-multiple-threads)
-
-## Screenshots
-
-![Screenshot](screenshots/screenshot.png)

二進制
loading/multiple_threads_loading/icon.png


+ 0 - 3
loading/multiple_threads_loading/images/.gitignore

@@ -1,3 +0,0 @@
-# For this folder only, let's ignore all *.import files.
-# Otherwise, there would be over a thousand lines committed for no benefit.
-*.import

二進制
loading/multiple_threads_loading/images/icon_1.png


二進制
loading/multiple_threads_loading/images/icon_10.png


二進制
loading/multiple_threads_loading/images/icon_11.png


二進制
loading/multiple_threads_loading/images/icon_12.png


二進制
loading/multiple_threads_loading/images/icon_13.png


二進制
loading/multiple_threads_loading/images/icon_14.png


二進制
loading/multiple_threads_loading/images/icon_15.png


二進制
loading/multiple_threads_loading/images/icon_16.png


二進制
loading/multiple_threads_loading/images/icon_17.png


二進制
loading/multiple_threads_loading/images/icon_18.png


二進制
loading/multiple_threads_loading/images/icon_19.png


二進制
loading/multiple_threads_loading/images/icon_2.png


二進制
loading/multiple_threads_loading/images/icon_20.png


二進制
loading/multiple_threads_loading/images/icon_21.png


二進制
loading/multiple_threads_loading/images/icon_22.png


二進制
loading/multiple_threads_loading/images/icon_23.png


二進制
loading/multiple_threads_loading/images/icon_24.png


二進制
loading/multiple_threads_loading/images/icon_25.png


二進制
loading/multiple_threads_loading/images/icon_26.png


二進制
loading/multiple_threads_loading/images/icon_27.png


二進制
loading/multiple_threads_loading/images/icon_28.png


二進制
loading/multiple_threads_loading/images/icon_29.png


二進制
loading/multiple_threads_loading/images/icon_3.png


二進制
loading/multiple_threads_loading/images/icon_30.png


二進制
loading/multiple_threads_loading/images/icon_31.png


二進制
loading/multiple_threads_loading/images/icon_32.png


二進制
loading/multiple_threads_loading/images/icon_33.png


二進制
loading/multiple_threads_loading/images/icon_34.png


二進制
loading/multiple_threads_loading/images/icon_35.png


二進制
loading/multiple_threads_loading/images/icon_36.png


二進制
loading/multiple_threads_loading/images/icon_37.png


二進制
loading/multiple_threads_loading/images/icon_38.png


二進制
loading/multiple_threads_loading/images/icon_39.png


二進制
loading/multiple_threads_loading/images/icon_4.png


二進制
loading/multiple_threads_loading/images/icon_40.png


二進制
loading/multiple_threads_loading/images/icon_5.png


二進制
loading/multiple_threads_loading/images/icon_6.png


二進制
loading/multiple_threads_loading/images/icon_7.png


二進制
loading/multiple_threads_loading/images/icon_8.png


二進制
loading/multiple_threads_loading/images/icon_9.png


+ 0 - 5
loading/multiple_threads_loading/link_button.gd

@@ -1,5 +0,0 @@
-extends LinkButton
-
-func _on_LinkButton_button_up():
-	# warning-ignore:return_value_discarded
-	OS.shell_open("http://docs.godotengine.org/en/3.2/tutorials/io/background_loading.html#using-multiple-threads")

+ 0 - 219
loading/multiple_threads_loading/main.tscn

@@ -1,219 +0,0 @@
-[gd_scene load_steps=41 format=2]
-
-[ext_resource path="res://images/icon_1.png" type="Texture2D" id=1]
-[ext_resource path="res://images/icon_2.png" type="Texture2D" id=2]
-[ext_resource path="res://images/icon_3.png" type="Texture2D" id=3]
-[ext_resource path="res://images/icon_4.png" type="Texture2D" id=4]
-[ext_resource path="res://images/icon_5.png" type="Texture2D" id=5]
-[ext_resource path="res://images/icon_6.png" type="Texture2D" id=6]
-[ext_resource path="res://images/icon_7.png" type="Texture2D" id=7]
-[ext_resource path="res://images/icon_8.png" type="Texture2D" id=8]
-[ext_resource path="res://images/icon_9.png" type="Texture2D" id=9]
-[ext_resource path="res://images/icon_10.png" type="Texture2D" id=10]
-[ext_resource path="res://images/icon_11.png" type="Texture2D" id=11]
-[ext_resource path="res://images/icon_12.png" type="Texture2D" id=12]
-[ext_resource path="res://images/icon_13.png" type="Texture2D" id=13]
-[ext_resource path="res://images/icon_14.png" type="Texture2D" id=14]
-[ext_resource path="res://images/icon_15.png" type="Texture2D" id=15]
-[ext_resource path="res://images/icon_16.png" type="Texture2D" id=16]
-[ext_resource path="res://images/icon_17.png" type="Texture2D" id=17]
-[ext_resource path="res://images/icon_18.png" type="Texture2D" id=18]
-[ext_resource path="res://images/icon_19.png" type="Texture2D" id=19]
-[ext_resource path="res://images/icon_20.png" type="Texture2D" id=20]
-[ext_resource path="res://images/icon_21.png" type="Texture2D" id=21]
-[ext_resource path="res://images/icon_22.png" type="Texture2D" id=22]
-[ext_resource path="res://images/icon_23.png" type="Texture2D" id=23]
-[ext_resource path="res://images/icon_24.png" type="Texture2D" id=24]
-[ext_resource path="res://images/icon_25.png" type="Texture2D" id=25]
-[ext_resource path="res://images/icon_26.png" type="Texture2D" id=26]
-[ext_resource path="res://images/icon_27.png" type="Texture2D" id=27]
-[ext_resource path="res://images/icon_28.png" type="Texture2D" id=28]
-[ext_resource path="res://images/icon_29.png" type="Texture2D" id=29]
-[ext_resource path="res://images/icon_30.png" type="Texture2D" id=30]
-[ext_resource path="res://images/icon_31.png" type="Texture2D" id=31]
-[ext_resource path="res://images/icon_32.png" type="Texture2D" id=32]
-[ext_resource path="res://images/icon_33.png" type="Texture2D" id=33]
-[ext_resource path="res://images/icon_34.png" type="Texture2D" id=34]
-[ext_resource path="res://images/icon_35.png" type="Texture2D" id=35]
-[ext_resource path="res://images/icon_36.png" type="Texture2D" id=36]
-[ext_resource path="res://images/icon_37.png" type="Texture2D" id=37]
-[ext_resource path="res://images/icon_38.png" type="Texture2D" id=38]
-[ext_resource path="res://images/icon_39.png" type="Texture2D" id=39]
-[ext_resource path="res://images/icon_40.png" type="Texture2D" id=40]
-
-[node name="Node" type="Node"]
-
-[node name="ColorRect" type="ColorRect" parent="."]
-anchor_right = 1.0
-anchor_bottom = 1.0
-color = Color(0, 0, 0, 1)
-__meta__ = {
-"_edit_use_anchors_": false
-}
-
-[node name="Label" type="Label" parent="."]
-offset_left = 452.0
-offset_top = 272.0
-offset_right = 572.0
-offset_bottom = 286.0
-text = "Main scene loaded"
-
-[node name="Sprite1" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 1 )
-
-[node name="Sprite2" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 2 )
-
-[node name="Sprite3" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 3 )
-
-[node name="Sprite4" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 4 )
-
-[node name="Sprite5" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 5 )
-
-[node name="Sprite6" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 6 )
-
-[node name="Sprite7" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 7 )
-
-[node name="Sprite8" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 8 )
-
-[node name="Sprite9" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 9 )
-
-[node name="Sprite10" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 10 )
-
-[node name="Sprite11" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 11 )
-
-[node name="Sprite12" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 12 )
-
-[node name="Sprite13" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 13 )
-
-[node name="Sprite14" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 14 )
-
-[node name="Sprite15" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 15 )
-
-[node name="Sprite16" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 16 )
-
-[node name="Sprite17" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 17 )
-
-[node name="Sprite18" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 18 )
-
-[node name="Sprite19" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 19 )
-
-[node name="Sprite20" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 20 )
-
-[node name="Sprite21" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 21 )
-
-[node name="Sprite22" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 22 )
-
-[node name="Sprite23" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 23 )
-
-[node name="Sprite24" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 24 )
-
-[node name="Sprite25" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 25 )
-
-[node name="Sprite26" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 26 )
-
-[node name="Sprite27" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 27 )
-
-[node name="Sprite28" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 28 )
-
-[node name="Sprite29" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 29 )
-
-[node name="Sprite30" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 30 )
-
-[node name="Sprite31" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 31 )
-
-[node name="Sprite32" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 32 )
-
-[node name="Sprite33" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 33 )
-
-[node name="Sprite34" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 34 )
-
-[node name="Sprite35" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 35 )
-
-[node name="Sprite36" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 36 )
-
-[node name="Sprite37" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 37 )
-
-[node name="Sprite38" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 38 )
-
-[node name="Sprite39" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 39 )
-
-[node name="Sprite40" type="Sprite2D" parent="."]
-visible = false
-texture = ExtResource( 40 )

+ 0 - 33
loading/multiple_threads_loading/preload.gd

@@ -1,33 +0,0 @@
-extends Node
-
-
-var queue
-
-
-func _ready():
-	# Initialize.
-	queue = preload("res://resource_queue.gd").new()
-	# Call after you instance the class to start the thread.
-	queue.start()
-
-
-func _process(_delta):
-	# Returns true if a resource is done loading and ready to be retrieved.
-	if queue.is_ready("res://main.tscn"):
-		set_process(false)
-		# Returns the fully loaded resource.
-		var next_scene = queue.get_resource("res://main.tscn").instantiate()
-		get_node(^"/root").add_child(next_scene)
-		get_node(^"/root").remove_child(self)
-		queue_free()
-	else:
-		# Get the progress of a resource.
-		var progress = round(queue.get_progress("res://main.tscn") * 100)
-		get_node(^"ProgressBar").set_value(progress)
-
-
-func _on_Button_button_up():
-	get_node(^"Button").hide()
-	set_process(true)
-	# Queue a resource.
-	queue.queue_resource("res://main.tscn", true)

+ 0 - 65
loading/multiple_threads_loading/preload.tscn

@@ -1,65 +0,0 @@
-[gd_scene load_steps=3 format=2]
-
-[ext_resource path="res://preload.gd" type="Script" id=1]
-[ext_resource path="res://link_button.gd" type="Script" id=2]
-
-[node name="Node" type="Node"]
-script = ExtResource( 1 )
-
-[node name="ColorRect" type="ColorRect" parent="."]
-anchor_right = 1.0
-anchor_bottom = 1.0
-color = Color(0.00390625, 0, 0, 1)
-
-[node name="ProgressBar" type="ProgressBar" parent="."]
-anchor_left = 0.5
-anchor_top = 0.5
-anchor_right = 0.5
-anchor_bottom = 0.5
-offset_left = -225.0
-offset_top = -66.0
-offset_right = 225.0
-offset_bottom = 66.0
-step = 1.0
-
-[node name="Button" type="Button" parent="."]
-anchor_left = 0.5
-anchor_top = 0.5
-anchor_right = 0.5
-anchor_bottom = 0.5
-offset_left = -223.0
-offset_top = -193.0
-offset_right = 224.0
-offset_bottom = -84.0
-text = "Load next scene"
-
-[node name="Label" type="Label" parent="."]
-anchor_left = 0.5
-anchor_right = 0.5
-offset_left = -267.0
-offset_top = 12.0
-offset_right = 267.0
-offset_bottom = 82.0
-text = "Multiple-treads loading demo
-The next scene contains 40 resource files. Loading is done using multiple threads.
-The download speed depends on the performance of your device.
-For more information, see:"
-__meta__ = {
-"_edit_use_anchors_": false
-}
-
-[node name="LinkButton" type="LinkButton" parent="."]
-anchor_left = 0.5
-anchor_right = 0.5
-offset_left = -233.0
-offset_top = 80.0
-offset_right = 233.0
-offset_bottom = 94.0
-text = "http://docs.godotengine.org/en/3.2/tutorials/io/background_loading.html"
-script = ExtResource( 2 )
-__meta__ = {
-"_edit_use_anchors_": false
-}
-
-[connection signal="button_up" from="Button" to="." method="_on_Button_button_up"]
-[connection signal="button_up" from="LinkButton" to="LinkButton" method="_on_LinkButton_button_up"]

+ 0 - 23
loading/multiple_threads_loading/project.godot

@@ -1,23 +0,0 @@
-; Engine configuration file.
-; It's best edited using the editor UI and not directly,
-; since the parameters that go here are not all obvious.
-;
-; Format:
-;   [section] ; section goes between []
-;   param=value ; assign values to parameters
-
-config_version=4
-
-[application]
-
-config/name="Multiple threads loading"
-config/description="This demo shows how you can organize
-background loading using multiple threads."
-run/main_scene="res://preload.tscn"
-config/icon="res://icon.png"
-
-[rendering]
-
-quality/driver/driver_name="GLES2"
-vram_compression/import_etc=true
-vram_compression/import_etc2=false

+ 0 - 145
loading/multiple_threads_loading/resource_queue.gd

@@ -1,145 +0,0 @@
-var thread
-var mutex
-var sem
-
-var time_max = 100 # Milliseconds.
-
-var queue = []
-var pending = {}
-
-func _lock(_caller):
-	mutex.lock()
-
-
-func _unlock(_caller):
-	mutex.unlock()
-
-
-func _post(_caller):
-	sem.post()
-
-
-func _wait(_caller):
-	sem.wait()
-
-
-func queue_resource(path, p_in_front = false):
-	_lock("queue_resource")
-	if path in pending:
-		_unlock("queue_resource")
-		return
-	elif ResourceLoader.has_cached(path):
-		var res = ResourceLoader.load(path)
-		pending[path] = res
-		_unlock("queue_resource")
-		return
-	else:
-		var res = ResourceLoader.load_interactive(path)
-		res.set_meta("path", path)
-		if p_in_front:
-			queue.insert(0, res)
-		else:
-			queue.push_back(res)
-		pending[path] = res
-		_post("queue_resource")
-		_unlock("queue_resource")
-		return
-
-
-func cancel_resource(path):
-	_lock("cancel_resource")
-	if path in pending:
-		if pending[path] is ResourceInteractiveLoader:
-			queue.erase(pending[path])
-		pending.erase(path)
-	_unlock("cancel_resource")
-
-
-func get_progress(path):
-	_lock("get_progress")
-	var ret = -1
-	if path in pending:
-		if pending[path] is ResourceInteractiveLoader:
-			ret = float(pending[path].get_stage()) / float(pending[path].get_stage_count())
-		else:
-			ret = 1.0
-	_unlock("get_progress")
-	return ret
-
-
-func is_ready(path):
-	var ret
-	_lock("is_ready")
-	if path in pending:
-		ret = !(pending[path] is ResourceInteractiveLoader)
-	else:
-		ret = false
-	_unlock("is_ready")
-	return ret
-
-
-func _wait_for_resource(res, path):
-	_unlock("wait_for_resource")
-	while true:
-		RenderingServer.sync()
-		OS.delay_usec(16000) # Wait approximately 1 frame.
-		_lock("wait_for_resource")
-		if queue.size() == 0 or queue[0] != res:
-			return pending[path]
-		_unlock("wait_for_resource")
-
-
-func get_resource(path):
-	_lock("get_resource")
-	if path in pending:
-		if pending[path] is ResourceInteractiveLoader:
-			var res = pending[path]
-			if res != queue[0]:
-				var pos = queue.find(res)
-				queue.remove(pos)
-				queue.insert(0, res)
-
-			res = _wait_for_resource(res, path)
-			pending.erase(path)
-			_unlock("return")
-			return res
-		else:
-			var res = pending[path]
-			pending.erase(path)
-			_unlock("return")
-			return res
-	else:
-		_unlock("return")
-		return ResourceLoader.load(path)
-
-
-func thread_process():
-	_wait("thread_process")
-	_lock("process")
-
-	while queue.size() > 0:
-		var res = queue[0]
-		_unlock("process_poll")
-		var ret = res.poll()
-		_lock("process_check_queue")
-
-		if ret == ERR_FILE_EOF or ret != OK:
-			var path = res.get_meta("path")
-			if path in pending: # Else, it was already retrieved.
-				pending[res.get_meta("path")] = res.get_resource()
-			# Something might have been put at the front of the queue while
-			# we polled, so use erase instead of remove.
-			queue.erase(res)
-	_unlock("process")
-
-
-func thread_func(_u):
-	while true:
-		thread_process()
-
-
-func start():
-	mutex = Mutex.new()
-	sem = Semaphore.new()
-	thread = Thread.new()
-	thread.start(self, "thread_func", 0)

+ 0 - 0
loading/multiple_threads_loading/screenshots/.gdignore


部分文件因文件數量過多而無法顯示