mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2025-12-16 13:30:07 +01:00
Style tweaks and add import files to multiple threads loading demo
This commit is contained in:
34
loading/multiple_threads_loading/icon.png.import
Normal file
34
loading/multiple_threads_loading/icon.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.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=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
3
loading/multiple_threads_loading/images/.gitignore
vendored
Normal file
3
loading/multiple_threads_loading/images/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# For this folder only, let's ignore all *.import files.
|
||||
# Otherwise, there would be over a thousand lines committed for no benefit.
|
||||
*.import
|
||||
@@ -1,33 +1,33 @@
|
||||
extends Node
|
||||
|
||||
|
||||
var Queue
|
||||
var queue
|
||||
|
||||
|
||||
func _ready():
|
||||
# Initialize
|
||||
Queue = preload("res://resource_queue.gd").new()
|
||||
# Initialize.
|
||||
queue = preload("res://resource_queue.gd").new()
|
||||
# Call after you instance the class to start the thread.
|
||||
Queue.start()
|
||||
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"):
|
||||
# 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").instance()
|
||||
# Returns the fully loaded resource.
|
||||
var next_scene = queue.get_resource("res://main.tscn").instance()
|
||||
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 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)
|
||||
# Queue a resource.
|
||||
queue.queue_resource("res://main.tscn", true)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
script/source = "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\")
|
||||
"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user